:root {
  color-scheme: light;
  --ink: #1c2430;
  --muted: #667085;
  --line: #d9dee7;
  --paper: #ffffff;
  --soft: #f4f6f8;
  --brand: #116466;
  --brand-dark: #0b4647;
  --accent: #d79f2b;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f5;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

button:hover {
  background: var(--brand-dark);
}

button.secondary {
  background: #e5ebee;
  color: var(--ink);
}

button.secondary:hover {
  background: #d6dee3;
}

button.danger {
  background: #fef3f2;
  color: var(--danger);
}

button.danger:hover {
  background: #fee4e2;
}

button.icon {
  width: 42px;
  padding: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 11px 12px;
}

textarea {
  min-height: 170px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 0.92rem;
  font-weight: 700;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
}

.shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 44px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.2rem;
  font-weight: 850;
}

.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs button {
  min-height: 36px;
  background: transparent;
  color: var(--muted);
}

.tabs button.active {
  background: #e3f0ef;
  color: var(--brand-dark);
}

.compact-tabs {
  margin-bottom: 14px;
}

.result-filters {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(2, minmax(130px, 0.8fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.result-filters input,
.result-filters select {
  padding: 9px 10px;
}

.compact-tabs button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
}

.content {
  padding: 24px clamp(16px, 4vw, 44px) 48px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.6fr);
  gap: 20px;
  align-items: start;
}

.setup-panel {
  width: min(860px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.editor-step {
  width: min(1100px, 100%);
  margin: 0 auto;
}

.draft-step {
  width: min(1260px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.step-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.step-heading h1 {
  margin: 0;
}

.back-button {
  margin-bottom: 14px;
}

.previous-exams {
  padding: 14px;
}

.previous-exams h2 {
  font-size: 1.15rem;
}

.compact-filter {
  margin-bottom: 12px;
}

.compact-filter select {
  padding: 9px 10px;
}

.compact-exam-list {
  display: grid;
  gap: 10px;
  max-height: 660px;
  overflow: auto;
  padding-right: 2px;
}

.compact-exam-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.compact-exam-card strong {
  display: block;
  line-height: 1.25;
}

.compact-exam-card p {
  margin: 6px 0 8px;
}

.compact-empty {
  padding: 16px;
}

.setup-header {
  display: grid;
  gap: 8px;
}

.setup-header h1 {
  margin-bottom: 0;
}

.class-start {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.selected-class-banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 6px;
  background: #e3f0ef;
  color: var(--brand-dark);
}

.selected-class-banner span {
  color: var(--muted);
  font-weight: 800;
}

.inline-button {
  min-height: 34px;
  margin-left: 10px;
  vertical-align: middle;
}

.wide-action {
  width: 100%;
}

.panel,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.panel h1,
.panel h2,
.panel h3 {
  margin: 0 0 14px;
}

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

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > * {
  min-width: 0;
}

.compact-actions {
  align-items: flex-start;
  flex-wrap: wrap;
}

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

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

.exam-group {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.exam-group h3,
.topic-group h4 {
  margin: 0;
}

.topic-group {
  padding: 10px;
  border-radius: 8px;
  background: #f7f9fa;
}

.card {
  padding: 14px;
}

.card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px #d7eeee;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #f2f4f7;
  color: #344054;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 800;
}

.qr {
  width: 150px;
  height: 150px;
  flex: 0 0 150px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.qr-row {
  margin-top: 12px;
  align-items: flex-start;
}

.question {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.question-edit {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.question-edit:nth-child(odd) {
  background: #f3f5f7;
}

.question-edit:nth-child(even) {
  background: #ffffff;
}

.hidden {
  display: none !important;
}

.question-picture-tools {
  display: grid;
  gap: 10px;
}

.keyword-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.choice-editor-list {
  display: grid;
  gap: 10px;
}

.choice-editor-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
}

.choice-editor-row input[type="radio"] {
  appearance: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}

.choice-editor-row input[type="radio"]::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  transform: scale(0);
  background: var(--brand);
}

.choice-editor-row input[type="radio"]:checked {
  border-color: var(--brand);
}

.choice-editor-row input[type="radio"]:checked::before {
  transform: scale(1);
}

.choice-letter {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #667085;
  font-weight: 850;
}

.question-edit textarea[name="prompt"],
.question-edit textarea[name="answer"],
.question-edit textarea[name="choices"],
.question-edit textarea[name="keywords"] {
  min-height: 92px;
}

.question-image,
.student-question-image {
  display: block;
  max-width: min(100%, 520px);
  max-height: 280px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.student-question-image {
  max-height: 340px;
}

.choice {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-weight: 500;
}

.choice input {
  width: auto;
  margin-top: 4px;
}

.choice:has(input:checked) .choice-letter {
  background: #34c79b;
  border-color: #34c79b;
  color: #fff;
}

.blank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.student-page {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 24px 14px;
}

.student-box {
  width: min(820px, 100%);
}

.status {
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff8e6;
  color: #6b4a00;
}

.error {
  background: #fef3f2;
  color: var(--danger);
}

.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.submission {
  display: grid;
  gap: 12px;
}

.score-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 0;
}

.answer-review {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.student-answer {
  color: #175cd3;
  font-weight: 700;
  line-height: 1.45;
}

@media (max-width: 850px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .draft-step {
    grid-template-columns: 1fr;
  }

  .result-filters {
    grid-template-columns: 1fr;
  }

  .card-header,
  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .selected-class-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .answer-review {
    grid-template-columns: 1fr;
  }
}
