:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-strong: #f9fbff;
  --text: #17202a;
  --muted: #64748b;
  --line: #d9e1ec;
  --blue: #2457c5;
  --teal: #087f75;
  --green: #15803d;
  --red: #b42318;
  --amber: #a15c00;
  --shadow: 0 18px 45px rgba(33, 46, 74, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial,
    sans-serif;
  line-height: 1.55;
}

button,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

button:active {
  transform: translateY(1px);
}

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

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.85rem;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1rem;
  letter-spacing: 0;
}

.status-strip,
.question-panel,
.result-panel,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
}

.stat {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid #edf1f7;
}

.stat span {
  display: block;
  color: var(--blue);
  font-size: 1.3rem;
  font-weight: 750;
}

.stat.good span {
  color: var(--green);
}

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

.stat small,
.year-filter span {
  color: var(--muted);
  font-size: 0.78rem;
}

.year-filter {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f3f7f6;
  border: 1px solid #d6ebe8;
}

.year-filter select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #bfd3d0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.question-panel {
  margin-top: 14px;
  padding: 16px;
}

.progress-row {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf6;
}

#progressBar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 180ms ease;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.question-label {
  margin: 0 0 8px;
  font-size: 0.96rem;
  font-weight: 750;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: #21468b;
  font-size: 0.78rem;
  white-space: nowrap;
}

.tag.warn {
  background: #fff7e8;
  color: var(--amber);
}

.tag.neutral {
  background: #eef2f7;
  color: #475569;
}

.stem {
  margin: 18px 0;
  padding: 16px;
  border-radius: 8px;
  background: #f9fbff;
  border: 1px solid #e5edf8;
  font-size: 1.06rem;
  white-space: pre-wrap;
}

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

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 10px;
  min-height: 52px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.option:hover {
  border-color: #9fb5d5;
  background: #fbfdff;
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option .letter {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #edf2f8;
  color: #34506f;
  font-weight: 750;
}

.option .option-text {
  min-width: 0;
  padding-top: 4px;
}

.option.selected {
  border-color: var(--blue);
  background: #f0f6ff;
}

.option.selected .letter {
  background: var(--blue);
  color: #fff;
}

.option.correct {
  border-color: rgba(21, 128, 61, 0.5);
  background: #effaf3;
}

.option.correct .letter {
  background: var(--green);
  color: #fff;
}

.option.wrong {
  border-color: rgba(180, 35, 24, 0.45);
  background: #fff3f2;
}

.option.wrong .letter {
  background: var(--red);
  color: #fff;
}

.subjective-box textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #fff;
}

.subjective-box textarea:focus,
.year-filter select:focus,
button:focus-visible,
.option:focus-within {
  outline: 3px solid rgba(36, 87, 197, 0.18);
  outline-offset: 2px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.actions #submitButton {
  grid-column: 1 / -1;
  grid-row: 1;
}

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

.solid {
  background: #18324f;
  color: #fff;
}

.ghost {
  background: #fff;
  color: #27364a;
  border-color: var(--line);
}

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

.result-panel {
  margin-top: 14px;
  padding: 16px;
}

.result-title {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef2f7;
  color: #334155;
  font-weight: 750;
}

.result-title.correct {
  background: #eaf8ef;
  color: var(--green);
}

.result-title.wrong,
.result-title.blank {
  background: #fff1ef;
  color: var(--red);
}

.result-title.subjective,
.result-title.unjudged {
  background: #fff7e8;
  color: var(--amber);
}

.answer-block,
.evidence-block {
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid #edf1f7;
}

.answer-block {
  margin-bottom: 12px;
  white-space: pre-wrap;
}

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

.evidence-block p {
  margin-bottom: 10px;
  color: #334155;
}

.source-list {
  display: grid;
  gap: 8px;
}

.source-link {
  display: block;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #d7e7ff;
  background: #f5f9ff;
  color: var(--blue);
  text-decoration: none;
}

.source-link small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.textbook-block {
  margin-top: 14px;
}

.page-grid {
  display: grid;
  gap: 12px;
}

.page-figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.page-figure figcaption {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.page-figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #eef2f7;
}

.empty-state {
  margin-top: 14px;
  padding: 22px;
  text-align: center;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 24px;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(190px, 230px);
  }

  .year-filter {
    grid-column: auto;
  }

  .question-panel,
  .result-panel {
    padding: 22px;
  }

  .actions {
    grid-template-columns: 132px 1fr 132px;
    align-items: center;
  }

  .actions #submitButton {
    grid-column: 2;
    grid-row: auto;
  }

  .page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (min-width: 1040px) {
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
  }

  .topbar,
  .status-strip {
    grid-column: 1 / -1;
  }

  .question-panel,
  .result-panel,
  .empty-state {
    margin-top: 0;
  }

  .result-panel {
    align-self: start;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow: auto;
  }

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