:root {
  --ink: #172121;
  --muted: #66716f;
  --line: #dce3df;
  --panel: #ffffff;
  --page: #f7f8f4;
  --accent: #176b5b;
  --accent-strong: #0d5145;
  --red: #bc3a37;
  --green: #178454;
  --amber: #a05d00;
  --shadow: 0 14px 38px rgba(21, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

body {
  margin: 0;
}

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

a:hover {
  text-decoration: underline;
}

button,
.button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  min-height: 38px;
  padding: 8px 13px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  border-color: #aab9b4;
  text-decoration: none;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.danger {
  border-color: #e8b4b1;
  color: var(--red);
}

.ghost {
  background: transparent;
}

.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 0.9rem;
}

.large {
  min-height: 48px;
  padding-inline: 22px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 11px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #2a3533;
  font-weight: 650;
}

table {
  border-collapse: collapse;
  table-layout: auto;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: #465552;
  font-size: 0.86rem;
  font-weight: 750;
}

code {
  background: #edf2ef;
  border-radius: 5px;
  display: inline-block;
  max-width: min(72vw, 560px);
  overflow-wrap: anywhere;
  padding: 3px 5px;
}

pre {
  background: #f1f4f1;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: auto;
  padding: 13px;
  white-space: pre-wrap;
}

.admin-header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 38px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--ink);
  font-weight: 850;
}

.topnav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topnav a,
.topnav button {
  border: 0;
  color: var(--muted);
  min-height: 32px;
  padding: 5px 8px;
}

.topnav a:hover,
.topnav button:hover {
  color: var(--accent-strong);
  text-decoration: none;
}

.container {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px clamp(16px, 4vw, 38px) 60px;
}

.page-head {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-head > div:first-child {
  min-width: 0;
}

h1,
h2 {
  margin: 0 0 8px;
}

h1 {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
}

h2 {
  font-size: 1.16rem;
}

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

.panel,
.login-panel,
.consent-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
}

.login-panel {
  margin: 8vh auto;
  max-width: 460px;
}

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

.two-col,
.grid-form {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.inline-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.export-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-form select {
  min-width: 220px;
  width: auto;
}

.sr-only {
  height: 1px;
  left: -10000px;
  overflow: hidden;
  position: absolute;
  top: auto;
  width: 1px;
}

.actions,
.row-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-head .actions {
  justify-content: flex-end;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

.help-card {
  box-shadow: none;
}

.help-card h2 {
  margin-bottom: 12px;
}

.help-card p,
.help-card li {
  color: var(--muted);
  line-height: 1.55;
}

.help-card p:last-child,
.help-card ol:last-child,
.help-card ul:last-child {
  margin-bottom: 0;
}

.help-card ol,
.help-card ul {
  padding-left: 22px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metric strong {
  display: block;
  font-size: 2rem;
}

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

.small-input {
  max-width: 86px;
}

.pill {
  background: #edf3ef;
  border-radius: 999px;
  color: #3c4d49;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  margin-left: 9px;
  padding: 3px 8px;
}

.format-help {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 13px;
}

.type-settings[hidden] {
  display: none;
}

.field-note {
  align-self: end;
  background: #f3f7f4;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #40504d;
  line-height: 1.45;
  padding: 11px 13px;
}

.quiz-list {
  display: grid;
  gap: 8px;
}

.quiz-pick {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 11px;
}

.quiz-pick input[type="checkbox"] {
  width: auto;
}

.quiz-pick span {
  display: grid;
  font-weight: 750;
}

.quiz-pick em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 500;
}

.flash {
  background: #fff9e9;
  border: 1px solid #f2d99a;
  border-radius: 7px;
  color: #6d4600;
  margin-bottom: 16px;
  padding: 11px 13px;
}

.mini-table {
  margin-top: 10px;
  min-width: 0;
  width: max-content;
  max-width: 100%;
}

.breakdown-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 6px;
}

.breakdown-scroll .mini-table {
  min-width: min(720px, 100%);
}

.breakdown-scroll th,
.breakdown-scroll td {
  max-width: 260px;
  white-space: normal;
}

.breakdown-scroll td:nth-child(1) {
  max-width: 280px;
}

.participant-shell {
  background: #fbfbf8;
  min-height: 100vh;
}

.consent-screen {
  display: grid;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 44px);
  place-items: center;
}

.consent-card {
  max-width: 760px;
  width: 100%;
}

.center {
  text-align: center;
}

.prose {
  color: #293533;
  line-height: 1.65;
}

.prose p {
  margin: 0 0 1em;
}

.checkline {
  align-items: start;
  display: flex;
  gap: 10px;
}

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

.progress-wrap {
  background: #e2e8e4;
  height: 9px;
  width: 100%;
}

.progress {
  background: var(--accent);
  height: 100%;
  transition: width 160ms ease;
}

.participant-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.9rem;
  justify-content: space-between;
  padding: 12px clamp(14px, 4vw, 38px);
}

.lextale-screen {
  align-items: center;
  display: grid;
  min-height: calc(100vh - 60px);
  padding: 20px;
}

.lex-form {
  display: grid;
  gap: clamp(34px, 8vh, 70px);
  justify-items: center;
}

.word {
  font-size: clamp(3.2rem, 11vw, 8rem);
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1;
  max-width: 94vw;
  overflow-wrap: anywhere;
  text-align: center;
}

.lex-actions {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(140px, 220px));
}

.lex-actions button {
  border: 0;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  min-height: 70px;
}

.lex-actions .yes {
  background: var(--green);
}

.lex-actions .no {
  background: var(--red);
}

.reading-screen {
  display: grid;
  gap: clamp(18px, 3vw, 34px);
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.05fr);
  margin: 0 auto;
  max-width: 1240px;
  padding: 18px clamp(16px, 4vw, 38px) 46px;
}

.passage,
.questions {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 28px);
}

.passage {
  align-self: start;
  max-height: calc(100vh - 98px);
  overflow: auto;
  position: sticky;
  top: 70px;
}

.passage summary {
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 12px;
}

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

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px;
}

legend {
  font-size: 1.08rem;
  font-weight: 800;
  padding: 0 4px;
}

.choice {
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 11px;
}

.choice:has(input:checked) {
  background: #eef7f3;
  border-color: var(--accent);
}

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

.rating-field {
  border: 0;
  padding: 0;
}

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

.stars label {
  display: inline-grid;
}

.stars input {
  position: absolute;
  opacity: 0;
}

.stars span {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-flex;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.stars input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 780px) {
  .admin-header,
  .page-head {
    display: grid;
  }

  .page-head .actions {
    justify-content: flex-start;
  }

  .export-form,
  .export-form select,
  .export-form button {
    width: 100%;
  }

  .metric-grid,
  .help-grid,
  .two-col,
  .grid-form,
  .reading-screen {
    grid-template-columns: 1fr;
  }

  .panel {
    overflow-x: auto;
  }

  .lex-actions {
    grid-template-columns: 1fr;
    width: min(420px, 100%);
  }

  .reading-screen {
    padding-top: 8px;
  }

  .passage {
    max-height: 42vh;
    position: sticky;
    top: 0;
    z-index: 3;
  }
}
