:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #eef6f2;
  --ink: #20252b;
  --muted: #62707d;
  --line: #d8dfe7;
  --green: #236a57;
  --blue: #245e9f;
  --amber: #a56d18;
  --red: #b4423a;
  --shadow: 0 14px 34px rgba(31, 38, 46, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, rgba(36, 94, 159, 0.08), transparent 280px), var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.58;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.topbar,
.toolbar,
.question-head,
.program-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 18px;
}

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

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 2px;
  font-size: 1.72rem;
  line-height: 1.24;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.18rem;
  line-height: 1.35;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.eyebrow,
.muted,
.toolbar p {
  color: var(--muted);
}

.eyebrow,
.toolbar p {
  margin: 0;
}

.panel,
.question-card,
.program-card,
.record-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.metric {
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.metric strong {
  display: block;
  color: var(--green);
  font-size: 1.4rem;
  line-height: 1.2;
}

.metric span,
.field span {
  color: var(--muted);
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fbfcfd;
}

.top-actions,
.toolbar-actions,
.tabs,
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-actions,
.toolbar-actions {
  justify-content: flex-end;
}

.tabs {
  margin-bottom: 14px;
}

.btn,
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 8px 13px;
  font-weight: 800;
}

.btn.primary,
.tab-btn.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.btn.warning {
  border-color: rgba(165, 109, 24, 0.45);
  background: #fff8ec;
  color: #754c0f;
}

.tab-btn {
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar,
.result {
  margin-bottom: 14px;
}

.result {
  display: none;
}

.result.visible {
  display: block;
}

.question-list,
.topic-grid {
  display: grid;
  gap: 12px;
}

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

.question-card,
.program-card,
.record-card {
  padding: 16px;
}

.stem {
  margin: 8px 0 10px;
  font-weight: 700;
}

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.tag {
  background: var(--panel-soft);
  color: var(--green);
}

.pill {
  border: 1px solid rgba(36, 94, 159, 0.25);
  background: #eef5fc;
  color: #264d7c;
}

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

.option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.option input {
  margin-top: 4px;
  flex: 0 0 auto;
}

.option.correct {
  border-color: rgba(35, 106, 87, 0.4);
  background: #edf7f3;
}

.option.wrong {
  border-color: rgba(180, 66, 58, 0.4);
  background: #fff0ef;
}

.analysis {
  display: none;
  margin-top: 12px;
  border-left: 4px solid var(--green);
  padding: 10px 12px;
  background: #f7fbf9;
  color: #35404a;
}

.show-analysis .analysis {
  display: block;
}

.program-card textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.5;
}

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

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

.score-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.score-box strong {
  display: block;
  color: var(--blue);
  font-size: 1.35rem;
}

pre {
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #f4f6f8;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
}

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

@media (max-width: 920px) {
  .hero,
  .sample-grid,
  .score-grid,
  .topic-grid {
    grid-template-columns: 1fr;
  }

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

  .toolbar,
  .topbar,
  .question-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .toolbar-actions {
    justify-content: flex-start;
  }
}

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

  .metric-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.42rem;
  }
}
