:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #eef3ee;
  --ink: #17211c;
  --muted: #667067;
  --line: #d8dfd7;
  --green: #177245;
  --blue: #245c8c;
  --amber: #b9652d;
  --red: #a33a3a;
  --shadow: 0 16px 34px rgba(36, 48, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: var(--blue);
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar,
.results-head,
.nav-row,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.results-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1,
.results-head h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.04;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.notice,
.legal-note {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #d9caa7;
  border-radius: 8px;
  background: #fff8e8;
  color: #51452a;
  line-height: 1.45;
}

.intro-panel,
.test-view,
.summary-panel,
.detail-section,
.question-panel,
.progress-panel,
.score-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 22px;
  padding: 24px;
}

.intro-panel h2 {
  margin: 0 0 10px;
  font-size: 30px;
}

.intro-panel p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

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

.factor-pill {
  min-height: 82px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fbfcfa;
}

.factor-pill:nth-child(2) {
  border-left-color: var(--blue);
}

.factor-pill:nth-child(3) {
  border-left-color: var(--amber);
}

.factor-pill:nth-child(4) {
  border-left-color: var(--red);
}

.factor-pill strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.factor-pill span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.consent-box {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.check-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  line-height: 1.45;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--green);
}

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

.test-view {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.progress-panel {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 18px;
  box-shadow: none;
}

.progress-ring {
  width: 126px;
  height: 126px;
  display: grid;
  place-content: center;
  border: 12px solid var(--surface-soft);
  border-top-color: var(--green);
  border-right-color: var(--blue);
  border-radius: 50%;
  text-align: center;
}

.progress-ring span {
  display: block;
  font-size: 34px;
  font-weight: 850;
}

.progress-ring small {
  color: var(--muted);
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.question-panel {
  padding: 22px;
  box-shadow: none;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--muted);
  font-weight: 800;
}

.question-text {
  min-height: 120px;
  margin: 0 0 18px;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.likert {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.likert button {
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f6;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.likert button:hover,
.likert button:focus-visible {
  border-color: var(--green);
  outline: 2px solid transparent;
}

.likert button.active {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.answer-hint {
  display: none;
  margin: 0 0 12px;
  color: var(--red);
  font-weight: 750;
}

.answer-hint.visible {
  display: block;
}

.nav-row {
  justify-content: space-between;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  background: var(--green);
  color: #ffffff;
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #a9b7ad;
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:disabled {
  color: #8a948c;
  cursor: not-allowed;
  background: #f0f2ef;
}

.hidden {
  display: none !important;
}

.results-view {
  display: grid;
  gap: 18px;
}

.summary-panel,
.detail-section {
  padding: 18px;
}

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

.summary-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

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

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

.score-card {
  padding: 16px;
}

.score-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.score-head h3,
.detail-section h3,
.legal-note h3 {
  margin: 0;
  font-size: 20px;
}

.score-percent {
  color: var(--blue);
  font-size: 24px;
  font-weight: 850;
}

.track {
  height: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.score-card p,
.legal-note p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.score-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

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

.facet {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

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

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

.admin-input {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.admin-table {
  display: grid;
  gap: 12px;
}

.admin-session {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.admin-session-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-session-head strong,
.admin-session-head span {
  display: block;
}

.admin-session-head span {
  color: var(--muted);
}

.status-badge {
  align-self: start;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink) !important;
  font-weight: 800;
  white-space: nowrap;
}

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

.mini-scores div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mini-scores span,
.mini-scores strong {
  display: block;
}

.mini-scores span {
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
}

.mini-scores strong {
  color: var(--blue);
  font-size: 20px;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 16px, 720px);
    padding: 10px 0 28px;
  }

  .topbar,
  .results-head,
  .intro-panel,
  .test-view {
    display: block;
  }

  .topbar h1,
  .results-head h2 {
    font-size: 31px;
    line-height: 1.14;
  }

  .text-link,
  .actions {
    margin-top: 14px;
  }

  .factor-strip,
  .summary-list,
  .score-grid,
  .facet-grid,
  .mini-scores {
    grid-template-columns: 1fr;
  }

  .intro-panel,
  .test-view,
  .question-panel,
  .progress-panel {
    padding: 14px;
  }

  .consent-box,
  .progress-panel {
    margin-top: 14px;
  }

  .progress-panel {
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
  }

  .progress-ring {
    width: 68px;
    height: 68px;
    border-width: 7px;
  }

  .progress-ring span {
    font-size: 24px;
  }

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

  .question-head {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
  }

  .question-text {
    min-height: 0;
    font-size: clamp(24px, 7vw, 32px);
  }

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

  .likert button {
    min-height: 52px;
    text-align: left;
  }

  .nav-row .primary-button,
  .nav-row .secondary-button {
    flex: 1;
    padding-inline: 10px;
  }

  .admin-session-head {
    display: grid;
  }
}

@media print {
  .topbar,
  .notice,
  .actions {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .score-grid,
  .facet-grid,
  .summary-list {
    grid-template-columns: 1fr;
  }
}
