:root {
  color-scheme: light;
  --ink: #1f2a2d;
  --muted: #5f6f73;
  --line: #dce8e5;
  --brand: #1f9f86;
  --soft: #f4fbf8;
  --paper: #fffdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--paper), var(--soft));
}

a {
  color: var(--brand);
  text-decoration: none;
}

.page {
  width: min(1080px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 72px 0;
}

.narrow {
  width: min(760px, calc(100vw - 40px));
}

.hero {
  min-height: 58vh;
  display: grid;
  align-content: center;
  gap: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 8vw, 84px);
  line-height: 1.04;
}

h2 {
  margin: 36px 0 12px;
  font-size: 24px;
}

p {
  font-size: 18px;
  line-height: 1.75;
}

.lead {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 22px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.actions a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.68);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

article {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

article p,
.narrow p {
  color: var(--muted);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: white;
  cursor: pointer;
}

.button-link {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: white;
}

button:hover {
  border-color: var(--brand);
}

.button-link:hover {
  border-color: var(--brand);
}

.primary-button {
  border-color: var(--brand);
  color: white;
  background: var(--brand);
}

.primary-button:hover {
  border-color: #178872;
  background: #178872;
}

.admin-page {
  display: grid;
  gap: 16px;
  padding: 32px 0 48px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.admin-header h1 {
  font-size: 34px;
  line-height: 1.16;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.82);
}

.admin-tabs a {
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-tabs a.active {
  color: white;
  background: var(--brand);
}

.batch-save-button {
  min-width: 132px;
  white-space: nowrap;
}

.batch-save-button:disabled {
  cursor: default;
  opacity: 0.5;
}

.batch-save-button:disabled:hover {
  border-color: var(--line);
}

.admin-controls,
.candidate-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-controls {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

.admin-message {
  min-height: 32px;
  margin: 0;
  color: var(--muted);
}

.candidate-list {
  display: grid;
  gap: 18px;
}

.candidate-item {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.candidate-meta {
  color: var(--brand);
  font-size: 14px;
  font-weight: 700;
}

.candidate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.management-page {
  width: min(1680px, calc(100vw - 48px));
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.metric-item,
.status-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.metric-item {
  display: grid;
  gap: 3px;
  text-align: left;
}

.metric-item strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.metric-item.active {
  border-color: rgba(31, 159, 134, 0.5);
  background: #e9f8f1;
}

.status-active {
  color: #087a5d;
  background: #e9f8f1;
}

.status-draft {
  color: #936111;
  background: #fff4d8;
}

.status-quarantined {
  color: #a23b2b;
  background: #ffe9e3;
}

.status-retired {
  color: #687075;
  background: #eef1f2;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.question-table {
  width: 100%;
  min-width: 1740px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.question-table th,
.question-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

.question-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8fbf9;
  font-size: 13px;
}

.question-table tr:last-child td {
  border-bottom: 0;
}

.question-table tbody tr:hover {
  background: #f8fbf9;
}

.question-table tbody tr.is-dirty {
  background: #fffaf0;
}

.question-table tbody tr.is-saved {
  background: #e9f8f1;
}

.question-table .col-id {
  width: 64px;
}

.question-table .col-status {
  width: 116px;
}

.question-table .col-prompt {
  width: 360px;
}

.question-table .col-answer {
  width: 130px;
}

.question-table .col-grade {
  width: 190px;
}

.question-table .col-difficulty {
  width: 86px;
}

.question-table .col-theme {
  width: 140px;
}

.question-table .col-score {
  width: 72px;
}

.question-table .col-feedback {
  width: 120px;
}

.question-table .col-review-note {
  width: 190px;
}

.question-table .col-version {
  width: 120px;
}

.question-table .col-updated {
  width: 128px;
}

.question-table .col-action {
  width: 78px;
}

.question-cell {
  line-height: 1.48;
  word-break: break-word;
}

.question-table select,
.question-table input {
  min-width: 0;
  height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.question-table select[data-field="status"] {
  width: 96px;
}

.question-table select[data-field="difficulty"] {
  width: 66px;
}

.question-table input[data-field="theme"] {
  width: 118px;
}

.question-table button {
  width: 54px;
  padding: 7px 0;
  white-space: nowrap;
}

.question-table button:disabled {
  cursor: default;
  opacity: 0.48;
}

.question-table button:disabled:hover {
  border-color: var(--line);
}

.grade-range-editor {
  display: flex;
  gap: 6px;
}

.grade-range-editor select {
  width: 86px;
}

.feedback-cell {
  line-height: 1.5;
  color: var(--muted);
}

.review-note-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  line-height: 1.45;
}

.reject-note-tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
  color: #a23b2b;
  background: #ffe9e3;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.reject-note-detail,
.reject-note-meta,
.empty-note {
  color: var(--muted);
  font-size: 12px;
}

.reject-note-detail {
  width: 100%;
  word-break: break-word;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 28px, 680px);
    padding: 48px 0;
  }

  .grid,
  .admin-controls,
  .candidate-grid {
    grid-template-columns: 1fr;
  }

  .admin-header {
    align-items: start;
    flex-direction: column;
  }

  .admin-header-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .admin-tabs {
    width: 100%;
  }

  .admin-tabs a {
    flex: 1;
    text-align: center;
  }

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