:root {
  color-scheme: light;
  --ink: #202a27;
  --muted: #66716c;
  --line: #dce2dd;
  --paper: #ffffff;
  --canvas: #f3f5f2;
  --green: #245c49;
  --green-dark: #174332;
  --green-pale: #eaf2ed;
  --red: #a6423a;
  --red-pale: #f9eeec;
  --shadow: 0 8px 26px rgba(30, 48, 39, 0.055);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 17px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
}
button,
input {
  font: inherit;
}
button {
  color: inherit;
}
a {
  color: inherit;
}
.page-shell {
  width: min(100% - 44px, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 0 62px;
}
.loading-state,
.notice {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--muted);
  font-size: 16px;
}
.flash-message {
  margin: 0 0 26px;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  max-width: 780px;
  margin-bottom: 14px;
  font-size: clamp(34px, 4.3vw, 48px);
  line-height: 1.12;
  letter-spacing: -0.035em;
}
h2 {
  margin-bottom: 9px;
  font-size: 23px;
  letter-spacing: -0.02em;
}
h3 {
  margin-bottom: 9px;
  font-size: 18px;
}
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 40px 0 17px;
}
.section-heading h2 {
  margin: 0;
}
.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.section-heading .history-count {
  margin-top: 5px;
}
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.mode-card,
.panel,
.question-card,
.result-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.mode-card {
  min-height: 235px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px;
}
.mode-card h2 {
  margin-bottom: 8px;
  font-size: 20px;
}
.mode-card p {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.mode-card .button {
  margin-top: auto;
}
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: white;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}
.button:focus-visible,
.option-button:focus-visible,
.tag-option:focus-within {
  outline: 3px solid rgba(194, 134, 53, 0.38);
  outline-offset: 2px;
}
.button.secondary {
  background: white;
  color: var(--green);
}
.button.secondary:hover {
  background: var(--green-pale);
}
.button.ghost {
  padding-inline: 12px;
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.button.ghost:hover {
  background: #edf0ed;
  color: var(--ink);
}
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.panel {
  padding: 26px;
}
.history-list {
  display: grid;
  gap: 0;
}
.history-row {
  display: grid;
  grid-template-columns:
    minmax(145px, 1fr) repeat(3, minmax(90px, auto))
    auto auto;
  align-items: center;
  gap: 16px;
  padding: 16px 2px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.history-row:first-child {
  border-top: 0;
}
.history-date {
  font-weight: 650;
}
.history-metric {
  color: var(--muted);
  white-space: nowrap;
  font-size: 14px;
}
.history-result {
  font-size: 14px;
  font-weight: 750;
}
.history-result.pass,
.text-pass {
  color: var(--green);
}
.history-result.fail,
.text-fail {
  color: var(--red);
}
.empty-state {
  padding: 20px 0 3px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
.page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-top .eyebrow {
  margin-bottom: 6px;
}
.page-top h1 {
  margin-bottom: 0;
  font-size: 34px;
}
.exam-status {
  display: flex;
  width: min(100%, 860px);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 13px;
}
.exam-summary {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.exam-summary strong {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.exam-summary span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.exam-summary .timer-value {
  color: var(--green-dark);
}
.exam-summary .timer-value.urgent {
  color: var(--red);
}
.exam-progress {
  width: min(100%, 860px);
  height: 6px;
  overflow: hidden;
  margin: 0 auto 20px;
  border-radius: 3px;
  background: #e4e9e5;
}
.exam-progress > span {
  display: block;
  height: 100%;
  background: var(--green);
}
.question-card {
  padding: 32px;
}
.exam-question-card {
  width: min(100%, 860px);
  margin: 0 auto;
}
.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
}
.question-number {
  color: var(--green);
  font-weight: 750;
}
.question-text {
  margin-bottom: 24px;
  font-size: 23px;
  font-weight: 620;
  line-height: 1.55;
  white-space: pre-line;
}
.question-image {
  display: block;
  max-width: min(100%, 590px);
  max-height: 360px;
  margin: 0 auto 21px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8f6;
}
.options {
  display: grid;
  gap: 10px;
}
.option-button {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px;
  text-align: left;
  font-size: 16px;
  line-height: 1.55;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  cursor: pointer;
}
.option-button:hover:not(:disabled) {
  border-color: #9bb7a7;
  background: #fbfcfb;
}
.option-letter {
  display: grid;
  flex: 0 0 27px;
  height: 27px;
  place-items: center;
  margin-top: -1px;
  border-radius: 5px;
  background: #edf0ed;
  color: #58635d;
  font-size: 13px;
  font-weight: 800;
}
.option-button.selected {
  border-color: var(--green);
  background: var(--green-pale);
}
.option-button.selected .option-letter {
  background: var(--green);
  color: white;
}
.option-button.correct {
  border-color: #8bad99;
  background: var(--green-pale);
}
.option-button.incorrect {
  border-color: #d5a09a;
  background: var(--red-pale);
}
.option-button:disabled {
  cursor: default;
  color: var(--ink);
}
.feedback {
  margin-top: 18px;
  padding: 16px 17px;
  border-radius: 7px;
  font-size: 15px;
  line-height: 1.6;
}
.feedback.correct {
  background: var(--green-pale);
  color: var(--green-dark);
}
.feedback.incorrect {
  background: var(--red-pale);
  color: #80372f;
}
.question-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.question-actions .helper {
  color: var(--muted);
  font-size: 14px;
}
.category-intro {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}
.category-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.category-toolbar span {
  color: var(--muted);
  font-size: 14px;
}
.category-search {
  width: 100%;
  max-width: 340px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font-size: 15px;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  padding: 17px 0 20px;
}
.tag-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.45;
}
.tag-option:hover {
  border-color: #a9bdaf;
}
.tag-option input {
  accent-color: var(--green);
  margin: 1px 0 0;
}
.category-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.category-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.category-actions .helper {
  color: var(--muted);
  font-size: 14px;
}
.result-card {
  overflow: hidden;
}
.result-banner {
  padding: 24px 26px;
  background: var(--green);
  color: white;
}
.result-banner.fail {
  background: #75423c;
}
.result-banner .eyebrow {
  color: rgba(255, 255, 255, 0.75);
}
.result-banner h1 {
  margin-bottom: 6px;
  font-size: 36px;
}
.result-banner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 16px;
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}
.result-stat {
  padding: 18px 21px;
  border-right: 1px solid var(--line);
}
.result-stat:last-child {
  border-right: 0;
}
.result-stat strong {
  display: block;
  margin-bottom: 5px;
  font-size: 27px;
}
.result-stat span {
  color: var(--muted);
  font-size: 13px;
}
.review-list {
  display: grid;
  gap: 10px;
  padding: 20px;
}
.review-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.review-item-head {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 9px;
  font-size: 11px;
}
.review-item-head strong {
  color: var(--green);
}
.review-item p {
  margin-bottom: 9px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
}
.review-answer {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.review-answer b {
  color: var(--ink);
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 0 20px 20px;
}
.inline-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (max-width: 760px) {
  :root {
    font-size: 16px;
  }
  .page-shell {
    width: min(100% - 28px, 680px);
    padding-top: 32px;
  }
  .mode-grid {
    grid-template-columns: 1fr;
  }
  .mode-card {
    min-height: 0;
    padding: 22px;
  }
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .history-row {
    grid-template-columns: minmax(100px, 1fr) auto auto;
    gap: 9px 12px;
  }
  .history-row .history-extra {
    display: none;
  }
  .history-row > :first-child {
    grid-column: 1;
    grid-row: 1;
  }
  .history-row > .history-metric:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }
  .history-row > .history-metric:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
  }
  .history-row .history-result {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
  }
  .history-row .history-actions {
    grid-column: 3;
    grid-row: 1 / span 3;
  }
  .result-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .result-stat:nth-child(2) {
    border-right: 0;
  }
  .result-stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}
@media (max-width: 440px) {
  .header-note {
    font-size: 0;
    gap: 0;
  }
  .header-note .status-dot {
    width: 9px;
    height: 9px;
  }
  .page-top {
    align-items: flex-start;
  }
  h1 {
    font-size: 32px;
  }
  .page-top h1 {
    font-size: 29px;
  }
  .exam-summary {
    gap: 8px;
    padding: 10px;
  }
  .exam-summary strong {
    font-size: 16px;
  }
  .question-card {
    padding: 20px;
  }
  .question-text {
    font-size: 19px;
  }
  .category-grid {
    grid-template-columns: 1fr;
  }
  .category-toolbar,
  .category-actions {
    align-items: flex-start;
    flex-direction: column;
  }
  .category-search {
    max-width: none;
  }
  .category-actions .button {
    width: 100%;
  }
  .section-heading {
    align-items: flex-start;
  }
  .section-heading .clear-attempts {
    align-self: center;
    padding-inline: 12px;
  }
  .history-row {
    grid-template-columns: 1fr auto auto;
  }
}
