:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #1c1b18;
  --muted: #625e56;
  --line: #d8d1c5;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-soft: #e1f3ef;
  --amber: #9a5b12;
  --amber-soft: #fff3dc;
  --blue: #275d8c;
  --blue-soft: #e8f0f8;
  --danger: #a33a2d;
  --shadow: 0 16px 42px rgba(25, 24, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

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

.app-shell {
  min-height: 100svh;
  padding: 20px;
}

.panel {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.narrow {
  width: min(760px, 100%);
}

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

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.22;
}

h1 {
  font-size: clamp(27px, 4vw, 34px);
}

h2 {
  font-size: 23px;
}

h3 {
  font-size: 19px;
}

h4 {
  font-size: 16px;
}

p {
  margin: 0 0 14px;
}

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

.small {
  font-size: 14px;
}

.instructions,
.criteria,
.choice-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbf7ee;
}

.criteria {
  border-left: 5px solid var(--teal);
  background: var(--teal-soft);
}

.instructions ul,
.criteria ul {
  margin: 10px 0 0;
  padding-left: 22px;
}

.worked-examples {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.worked-examples article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.worked-examples article p:last-child {
  margin-bottom: 0;
}

.locked-choice-summary {
  padding: 14px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal-soft);
}

.locked-choice-summary p {
  margin: 6px 0 0;
}

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

.field legend {
  font-weight: 750;
}

.field > label:has(input[type="radio"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.consent input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex: 0 0 auto;
}

.field label,
.question-label {
  font-weight: 750;
}

.text-input,
select,
textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.button {
  min-height: 48px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  font-weight: 760;
}

.button:hover,
.button:focus-visible {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

.button.secondary:hover,
.button.secondary:focus-visible {
  background: #eee8dc;
}

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

.progress-wrap {
  display: grid;
  min-width: 220px;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6dfd2;
}

.progress > div {
  height: 100%;
  background: var(--teal);
}

.report-tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 0;
  background: linear-gradient(var(--surface) 76%, rgba(255, 253, 248, 0));
}

.report-tab {
  display: flex;
  min-height: 52px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.report-tab strong {
  font-size: 16px;
}

.report-tab.active.a,
.report-tab.complete.a {
  border-color: var(--amber);
}

.report-tab.active.b,
.report-tab.complete.b {
  border-color: var(--blue);
}

.report-tab.active.a {
  background: var(--amber-soft);
  box-shadow: inset 0 0 0 1px var(--amber);
}

.report-tab.active.b {
  background: var(--blue-soft);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.report-card {
  display: grid;
  gap: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-strong);
}

.report-card.a {
  border-top: 5px solid var(--amber);
}

.report-card.b {
  border-top: 5px solid var(--blue);
}

.report-label,
.section-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.document-section {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.document-body {
  display: grid;
  gap: 12px;
}

.document-body p {
  margin: 0;
}

.document-body h3,
.document-body h4 {
  margin-top: 10px;
}

.document-body ul,
.document-body ol {
  margin: 0;
  padding-left: 24px;
}

.document-body li + li {
  margin-top: 7px;
}

.document-body code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #f0ebe1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
}

.document-body pre {
  overflow-x: auto;
  padding: 14px;
  border-radius: 7px;
  background: #f0ebe1;
  white-space: pre-wrap;
}

.document-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.document-body th,
.document-body td {
  padding: 7px 9px;
  border: 1px solid var(--line);
  text-align: left;
}

.viewing-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf7ee;
}

.viewing-gate p {
  margin: 4px 0 0;
}

.viewing-gate-grid {
  display: grid;
  min-width: 320px;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.viewing-gate-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.viewing-gate-item span {
  color: var(--muted);
  font-size: 13px;
}

.viewing-gate-item.complete {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.choice-panel {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.response-fields {
  display: grid;
  gap: 18px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.choice {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 780;
  text-align: center;
}

.choice-content {
  display: grid;
  gap: 5px;
}

.choice-option {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.choice-title {
  font-weight: 750;
  line-height: 1.35;
}

.choice input,
.rating-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 2px var(--teal);
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rating-choice {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.rating-choice.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 2px var(--teal);
}

.rating-scale {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.locked {
  opacity: 0.72;
}

.response-fields:disabled {
  cursor: not-allowed;
}

.response-fields:disabled .choice,
.response-fields:disabled .rating-choice {
  cursor: not-allowed;
}

.error {
  color: var(--danger);
  font-weight: 720;
}

.completion-code {
  display: inline-flex;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
  }

  .panel {
    min-height: 100svh;
    padding: 18px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .header {
    display: grid;
  }

  .progress-wrap {
    min-width: 0;
  }

  .report-tabs {
    top: 0;
  }

  .choice-grid,
  .rating-grid {
    grid-template-columns: 1fr;
  }

  .viewing-gate {
    align-items: stretch;
    flex-direction: column;
  }

  .viewing-gate-grid {
    min-width: 0;
  }

  .button-row {
    position: sticky;
    bottom: 0;
    margin: 20px -18px -18px;
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.96);
  }

  .button {
    flex: 1 1 140px;
  }
}
