:root {
  --ink: #172126;
  --muted: #5f6f75;
  --line: #d8e1dd;
  --paper: #ffffff;
  --bg: #eef4f1;
  --green: #237a57;
  --green-dark: #155c40;
  --blue: #2b6f9e;
  --gold: #b57621;
  --red: #b83a3a;
  --soft-green: #e4f3eb;
  --soft-blue: #e4f0f8;
  --soft-red: #fae7e5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #173a35;
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #a9d7bb;
  color: #12372f;
  font-weight: 800;
}

.brand h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.brand p,
.topbar p,
.exam-setup p,
.section-head p,
.run-head p,
.history-card p {
  margin: 0;
  color: var(--muted);
}

.brand p {
  color: #c6d9d3;
}

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

.subject-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border: 1px solid #3e6a61;
  border-radius: 8px;
  background: #214a43;
}

.subject-tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dcebe6;
  cursor: pointer;
  font-weight: 700;
}

.subject-tab.active,
.subject-tab:hover {
  background: #e9f1ee;
  color: #173a35;
}

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  color: #e9f1ee;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: #25534b;
  border-color: #47766c;
}

.summary-panel {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.summary-panel div {
  background: #214a43;
  border: 1px solid #3e6a61;
  border-radius: 8px;
  padding: 14px;
}

.summary-panel span {
  display: block;
  font-size: 28px;
  font-weight: 800;
}

.summary-panel small {
  color: #c9dbd6;
}

.workspace {
  padding: 28px;
  overflow: auto;
}

.topbar,
.control-row,
.exam-setup,
.section-head,
.run-head,
.history-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar {
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
}

h2,
h3,
h4 {
  margin: 0;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.control-row,
.exam-setup,
.section-head {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

select {
  min-width: 160px;
  padding: 10px 12px;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  min-height: 42px;
}

.primary-button {
  background: var(--green);
  color: white;
  font-weight: 700;
}

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

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

.ghost-button {
  background: #ffffff;
  color: var(--green-dark);
  border: 1px solid var(--line);
}

.paper,
.list {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.empty-state {
  min-height: 190px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.question-stack {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.question,
.mistake-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.question.correct {
  border-color: #9ac7ad;
  background: #fbfffc;
}

.question.wrong {
  border-color: #e6aaa5;
  background: #fffafa;
}

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

.question-meta span {
  background: var(--soft-blue);
  color: #245877;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.answers {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.option,
.checkline {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdfc;
}

.feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f4f8f6;
}

.feedback p {
  margin: 0 0 8px;
  line-height: 1.6;
}

.feedback p:last-child {
  margin-bottom: 0;
}

.ok {
  color: var(--green-dark);
}

.bad {
  color: var(--red);
}

.correction-inline {
  margin-top: 8px;
}

.result-box {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 8px;
  background: var(--soft-green);
  border: 1px solid #b9d9c6;
}

.result-box strong {
  font-size: 28px;
  color: var(--green-dark);
}

.timer {
  min-width: 86px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--soft-blue);
  color: var(--blue);
  font-weight: 800;
}

.list {
  display: grid;
  gap: 14px;
}

.mistake-card.mastered {
  opacity: 0.68;
  background: #f8faf9;
}

.history-card strong {
  font-size: 26px;
  color: var(--gold);
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .summary-panel {
    grid-template-columns: repeat(3, 1fr);
  }

  .topbar,
  .control-row,
  .exam-setup,
  .section-head,
  .run-head,
  .history-card {
    align-items: stretch;
    flex-direction: column;
  }

  select,
  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
