:root {
  color-scheme: light;
  --bg: #f4f0e6;
  --bg-deep: #e7eee8;
  --surface: #fffdf8;
  --surface-2: #edf4f0;
  --surface-3: #dfece7;
  --line: #b9cac2;
  --line-strong: #78958b;
  --text: #203a34;
  --muted: #516860;
  --dim: #596b64;
  --accent: #176f68;
  --accent-hover: #105e59;
  --accent-ink: #ffffff;
  --accent-soft: #dceee9;
  --blue: #376f86;
  --blue-soft: #dcebf1;
  --warning: #735414;
  --warning-soft: #fff3d2;
  --danger: #963f43;
  --danger-soft: #fbe8e6;
  --success: #356148;
  --success-soft: #e2f0e5;
  --focus: #9a4b0b;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 11px;
  --shadow: 0 20px 55px rgba(50, 73, 64, 0.13);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 253, 248, 0.94), transparent 34rem),
    radial-gradient(circle at 100% 24%, rgba(201, 224, 215, 0.65), transparent 36rem),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-deep) 100%);
  line-height: 1.58;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  max-width: 100%;
  color: inherit;
  font: inherit;
}

button,
a,
input,
select,
textarea,
[tabindex] {
  outline-offset: 4px;
}

:focus-visible {
  outline: 4px solid var(--focus);
}

a {
  color: var(--accent);
  font-weight: 650;
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-hover);
}

button {
  touch-action: manipulation;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 11px 16px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(32, 58, 52, 0.2);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.study-app {
  width: min(1460px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 44px) 14px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
}

.study-header {
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(190px, 0.75fr) minmax(220px, 1.25fr) minmax(460px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.93);
  box-shadow: 0 8px 28px rgba(61, 84, 74, 0.08);
  backdrop-filter: blur(12px);
}

.study-brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.study-brand strong,
.study-brand small {
  display: block;
}

.study-brand strong {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  font-size: 1.02rem;
  letter-spacing: 0.015em;
}

.study-brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #8fb4a8;
  border-radius: 14px;
  color: #125e58;
  background: var(--accent-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-weight: 850;
  letter-spacing: -0.03em;
}

.header-progress {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr);
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid #ccdad4;
  border-radius: 999px;
  background: #e5ece8;
}

.progress-track span {
  display: block;
  width: 3%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--accent));
  transition: width 220ms ease;
}

.header-actions {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.privacy-pill,
.status-pill,
.condition-pill,
.round-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: #f8faf7;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
}

.privacy-pill {
  border-color: #a7c6b7;
  background: var(--success-soft);
}

.privacy-pill span {
  color: var(--success);
}

#sessionTimer {
  min-width: 58px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
}

#pauseButton,
#stopButton {
  min-height: 44px;
  padding: 9px 13px;
}

#stopButton {
  border-color: #b8797c;
  color: #7d2d31;
  background: #fff8f6;
}

#stopButton:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.quiet-button,
.secondary-button,
.primary-button,
.danger-button,
.key-button,
.candidate-button {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 11px 17px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.35;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.quiet-button,
.secondary-button,
.key-button {
  color: #29473f;
  background: #f7faf7;
}

.quiet-button:hover,
.secondary-button:hover,
.key-button:hover {
  border-color: #527b70;
  background: #e9f1ed;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 5px 14px rgba(23, 111, 104, 0.18);
  text-decoration: none;
}

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

.danger-button {
  border-color: #bd7477;
  color: #7d2d31;
  background: var(--danger-soft);
}

.danger-button:hover {
  border-color: var(--danger);
  background: #f7dbd9;
}

@media (hover: hover) {
  .quiet-button:hover,
  .secondary-button:hover,
  .primary-button:hover,
  .danger-button:hover,
  .key-button:hover,
  .candidate-button:hover {
    transform: translateY(-1px);
  }
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
  transform: none !important;
}

.simulation-banner {
  padding: 11px 16px;
  border: 1px solid #d1b86d;
  border-radius: 13px;
  color: #624b16;
  background: #fff5d9;
  text-align: center;
  font-size: 0.9rem;
}

.study-screen {
  min-width: 0;
  min-height: 560px;
  display: grid;
  align-content: start;
  padding: clamp(24px, 4vw, 52px);
  border: 1px solid #c5d1ca;
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

/* The app moves focus here after each screen change for announcements. Keep
   the strong ring for interactive controls without outlining the whole page. */
.study-screen:focus-visible {
  outline: none;
}

.study-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 18px;
  padding: 2px 6px;
  color: var(--dim);
  font-size: 0.78rem;
}

.study-footer a {
  color: var(--muted);
}

#saveStatus[data-kind="saved"] {
  color: var(--success);
}

#saveStatus[data-kind="error"] {
  color: var(--danger);
  font-weight: 700;
}

.loading-card,
.centered-panel {
  width: min(780px, 100%);
  margin: auto;
  padding: clamp(24px, 5vw, 48px);
  text-align: center;
}

.spinner {
  width: 38px;
  height: 38px;
  display: inline-block;
  border: 4px solid #d5e1dc;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 15px;
  font-size: clamp(2rem, 4vw, 3.55rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h2 {
  font-size: clamp(1.4rem, 2.4vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.08rem;
  line-height: 1.3;
}

p,
li,
label,
button,
textarea {
  overflow-wrap: anywhere;
}

.eyebrow {
  margin-bottom: 9px;
  color: var(--accent);
  font-size: 0.77rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lead {
  max-width: 780px;
  color: #3f5c53;
  font-size: clamp(1.08rem, 1.7vw, 1.28rem);
  line-height: 1.55;
}

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

.small-copy {
  color: var(--muted);
  font-size: 0.9rem;
}

.study-byline {
  max-width: 780px;
  margin: -2px 0 20px;
  padding: 10px 13px;
  border-left: 4px solid #7da99b;
  border-radius: 0 11px 11px 0;
  color: #465f57;
  background: #edf5f1;
  font-size: 0.91rem;
  line-height: 1.5;
}

.study-byline strong {
  color: #2f5d45;
}

.study-byline a,
.study-contact-list a {
  color: #12645e;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.study-contact-list {
  display: grid;
  gap: 9px;
  margin: 9px 0 0;
}

.study-contact-list p {
  margin: 0;
  line-height: 1.45;
}

.study-contact-list p + p {
  padding-top: 9px;
  border-top: 1px solid #cfddd7;
}

.study-contact-list strong {
  color: #29483f;
}

.consent-wrap {
  width: min(1160px, 100%);
  margin: 0 auto;
}

.consent-wrap > .lead {
  margin-bottom: 24px;
}

.consent-key-info {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  align-items: start;
  gap: clamp(22px, 4vw, 42px);
  margin: 22px 0;
  border-color: #94b8ab;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(225, 241, 235, 0.84)),
    var(--surface);
  box-shadow: 0 10px 30px rgba(48, 82, 71, 0.09);
}

.consent-key-info h2 {
  margin-bottom: 12px;
}

.consent-key-info p:last-child {
  margin-bottom: 0;
}

.consent-facts {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.consent-facts > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid #afc8bf;
  border-radius: 13px;
  background: rgba(255, 253, 248, 0.82);
}

.consent-facts dt {
  margin-bottom: 4px;
  color: var(--dim);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.consent-facts dd {
  margin: 0;
  color: var(--text);
  font-weight: 750;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

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

.consent-grid .info-card {
  padding: clamp(20px, 3vw, 28px);
}

.consent-grid h2 {
  margin-bottom: 12px;
  color: #21463c;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
}

.consent-grid p:last-child {
  margin-bottom: 0;
}

.consent-list {
  display: grid;
  gap: 9px;
}

.consent-list li {
  position: relative;
  padding-left: 22px;
  color: #3f5c53;
}

.consent-list li::before {
  content: "";
  position: absolute;
  top: 0.68em;
  left: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
}

ol.consent-list {
  padding-left: 25px;
}

ol.consent-list li {
  padding-left: 5px;
}

ol.consent-list li::before {
  content: none;
}

.consent-agreement {
  width: min(940px, 100%);
  margin: 24px auto 0;
  padding: clamp(22px, 4vw, 34px);
  border: 2px solid #87aca0;
  background: #f6faf7;
  box-shadow: 0 10px 30px rgba(48, 82, 71, 0.08);
}

.study-export-grid code {
  overflow-wrap: anywhere;
}

.upload-confirmation {
  margin-top: 18px;
}

.consent-agreement h2 {
  margin-bottom: 9px;
}

.consent-agreement form {
  margin-top: 20px;
}

.consent-agreement .checkbox-field {
  padding: 12px 13px;
  border: 1px solid #c0d1ca;
  border-radius: 12px;
  background: #fffefa;
}

.consent-agreement .checkbox-field + .checkbox-field {
  margin-top: 10px;
}

.distribution-warning {
  margin: 20px 0 22px;
  border-width: 2px;
  border-left-width: 7px;
  box-shadow: 0 7px 22px rgba(121, 47, 51, 0.08);
}

.distribution-warning > strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.05rem;
}

.distribution-warning .consent-list {
  margin-top: 12px;
}

.distribution-warning .consent-list li {
  color: #713236;
}

.distribution-warning .consent-list li::before {
  background: var(--danger);
}

.welcome-grid,
.setup-grid,
.task-layout,
.feedback-grid,
.export-grid {
  min-width: 0;
  display: grid;
  gap: clamp(18px, 3vw, 26px);
}

.welcome-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(290px, 0.7fr);
  align-items: start;
}

.setup-grid,
.feedback-grid,
.export-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-card,
.form-card,
.goal-card,
.conversation-card,
.interaction-card,
.tlx-card,
.feedback-card,
.export-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(52, 78, 68, 0.05);
}

.info-card,
.form-card,
.feedback-card,
.export-card {
  padding: clamp(19px, 3vw, 30px);
}

.form-card {
  background: #fffefb;
}

.notice-card {
  padding: 16px 17px;
  border: 1px solid #d4bb6f;
  border-radius: 14px;
  color: #624a14;
  background: var(--warning-soft);
}

.notice-card p:last-child {
  margin-bottom: 0;
}

.notice-card.danger {
  border-color: #c68486;
  color: #792f33;
  background: var(--danger-soft);
}

.notice-card.success {
  border-color: #91b79f;
  color: #2d593f;
  background: var(--success-soft);
}

.check-list,
.plain-list,
.step-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list {
  display: grid;
  gap: 11px;
}

.check-list li {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 10px;
  color: var(--muted);
}

.check-list li::before {
  content: "✓";
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  margin-top: 1px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--success);
  font-size: 0.8rem;
  font-weight: 900;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 11px;
  margin-top: 24px;
}

.button-row.end {
  justify-content: flex-end;
}

.field,
.checkbox-field,
.radio-field {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.field + .field,
.checkbox-field + .checkbox-field {
  margin-top: 18px;
}

.field label,
.field-label {
  color: #29483f;
  font-weight: 750;
}

.field-help {
  color: var(--dim);
  font-size: 0.82rem;
}

input[type="text"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  background: #fffefa;
}

input[type="text"]:hover,
select:hover,
textarea:hover {
  border-color: #557e72;
}

input[type="text"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(154, 75, 11, 0.12);
}

textarea {
  min-height: 124px;
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #6c7d76;
  opacity: 1;
}

.checkbox-field {
  grid-template-columns: 25px minmax(0, 1fr);
  align-items: start;
  color: #304d44;
}

.checkbox-field input {
  width: 21px;
  height: 21px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.form-error {
  margin-top: 13px;
  color: var(--danger);
  font-weight: 750;
}

.compat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  margin: 19px 0;
}

.compat-item {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: #f7faf7;
}

.compat-item strong {
  display: block;
  color: var(--text);
}

.compat-item.pass strong::before {
  content: "✓ ";
  color: var(--success);
}

.compat-item.warn strong::before {
  content: "! ";
  color: var(--warning);
}

.tutorial-keys,
.key-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
}

kbd {
  min-width: 40px;
  display: inline-grid;
  place-items: center;
  padding: 5px 9px;
  border: 1px solid #7b958c;
  border-bottom-width: 3px;
  border-radius: 8px;
  color: #28463e;
  background: #f2f6f3;
  box-shadow: inset 0 1px 0 #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.2;
}

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

.task-header > * {
  min-width: 0;
}

.task-header h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
}

.task-layout {
  grid-template-columns: minmax(240px, 0.56fr) minmax(0, 1.44fr);
  align-items: start;
}

.task-sidebar {
  min-width: 0;
  display: grid;
  gap: 15px;
  position: sticky;
  top: 16px;
}

.goal-card {
  overflow: hidden;
  border-color: #a8c4ba;
}

.goal-card-header {
  padding: 13px 17px;
  color: #155f59;
  background: var(--accent-soft);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.goal-card-body {
  padding: 19px;
}

.goal-card-body ul {
  margin: 13px 0 0;
  padding-left: 21px;
  color: #304e45;
}

.goal-card-body li + li {
  margin-top: 8px;
}

.turn-meter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.turn-meter span {
  height: 9px;
  border-radius: 999px;
  background: #d8e1dc;
}

.turn-meter span.complete {
  background: var(--accent);
}

.turn-meter span.current {
  background: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.condition-help {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: #f4f8f5;
  font-size: 0.9rem;
}

.task-main {
  min-width: 0;
  display: grid;
  gap: 15px;
}

.conversation-card {
  padding: 17px;
  background: #fcfbf7;
}

.conversation-log {
  max-height: 280px;
  display: grid;
  gap: 12px;
  overflow: auto;
  padding: 2px 6px 2px 2px;
  scrollbar-color: #8ba69c #e7eeea;
}

.message-bubble {
  width: fit-content;
  max-width: min(82%, 720px);
  padding: 12px 15px;
  border: 1px solid #c8d3ce;
  border-radius: 16px 16px 16px 5px;
  color: #29473f;
  background: #eff2ef;
}

.message-bubble.participant {
  justify-self: end;
  border-color: #9cbeb2;
  border-radius: 16px 16px 5px 16px;
  color: #214a40;
  background: #dceee8;
}

.message-bubble.unresolved {
  border-color: #d09597;
  color: #7b3034;
  background: var(--danger-soft);
}

.message-speaker {
  display: block;
  margin-bottom: 4px;
  color: var(--dim);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.interaction-card {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  padding: clamp(19px, 3vw, 30px);
  border-color: #94b5aa;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(231, 243, 239, 0.88)),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 12px 32px rgba(47, 87, 75, 0.1);
}

.interaction-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--blue), #5b978c, var(--accent));
}

.interaction-head {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 17px;
  margin-bottom: 19px;
}

.interaction-head > * {
  min-width: 0;
}

.interaction-head h2 {
  margin-bottom: 5px;
}

.sign-ready,
.sign-active,
.writing-ready,
.writing-active {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 11px;
  text-align: center;
}

.timer-orb {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border: 2px solid #88a49a;
  border-radius: 50%;
  color: #405c53;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 6px 20px rgba(51, 81, 70, 0.08);
  font-variant-numeric: tabular-nums;
  font-size: 1.38rem;
  font-weight: 750;
}

.timer-orb.active {
  border-color: var(--danger);
  color: #7b2e32;
  background: #fff2f0;
  box-shadow: 0 0 0 8px rgba(150, 63, 67, 0.08);
  animation: timerPulse 1.8s ease-in-out infinite;
}

@keyframes timerPulse {
  50% {
    box-shadow: 0 0 0 12px rgba(150, 63, 67, 0.04);
  }
}

.candidate-stack {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.candidate-button {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  color: #294840;
  background: rgba(255, 255, 255, 0.82);
  text-align: left;
}

.candidate-button .rank {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #4e6860;
  background: #e8efeb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 750;
}

.candidate-button.selected {
  border-color: var(--accent);
  color: #173f37;
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(23, 111, 104, 0.15);
}

.candidate-button.selected .rank {
  color: #ffffff;
  background: var(--accent);
}

.candidate-button.resign-option {
  border-style: dashed;
  border-color: #c58486;
  color: #783236;
  background: #fff3f1;
}

.candidate-button.resign-option .rank {
  color: #793438;
  background: #f4dedd;
}

.candidate-button.resign-option.selected {
  border-color: var(--danger);
  background: var(--danger-soft);
  box-shadow: 0 0 0 3px rgba(150, 63, 67, 0.13);
}

.candidate-button.resign-option.selected .rank {
  color: #ffffff;
  background: var(--danger);
}

.top1-output {
  padding: clamp(21px, 4vw, 38px);
  border: 1px solid #91ada4;
  border-radius: 17px;
  color: #23453c;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 4px 0 0 var(--accent);
}

.top1-output small {
  display: block;
  margin-bottom: 9px;
  color: var(--dim);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top1-output p {
  margin: 0;
  font-size: clamp(1.24rem, 2vw, 1.72rem);
  line-height: 1.45;
}

.phone-frame {
  width: min(500px, 100%);
  margin: 0 auto;
  padding: 16px;
  border: 2px solid #779188;
  border-radius: 28px;
  background: #e8eeea;
  box-shadow: 0 12px 32px rgba(45, 69, 61, 0.14);
}

.phone-top {
  width: 88px;
  height: 5px;
  margin: 0 auto 15px;
  border-radius: 999px;
  background: #71887f;
}

.phone-frame textarea {
  min-height: 160px;
  background: #fffefa;
}

.photo-area {
  display: grid;
  gap: 15px;
}

.photo-drop {
  min-height: 190px;
  display: grid;
  place-items: center;
  padding: 20px;
  border: 2px dashed #77978c;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.66);
  text-align: center;
}

.photo-preview {
  width: min(100%, 660px);
  max-height: 400px;
  margin: 0 auto;
  display: block;
  object-fit: contain;
  border: 2px solid #829c93;
  border-radius: 14px;
  background: #f0eee8;
  box-shadow: 0 8px 24px rgba(44, 67, 59, 0.12);
}

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.next-turn-card {
  min-height: 270px;
  display: grid;
  align-content: center;
  justify-items: start;
}

.tlx-wrap {
  width: min(1080px, 100%);
  margin: 0 auto;
}

.tlx-intro {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 19px;
}

.tlx-intro > * {
  min-width: 0;
}

.tlx-card {
  display: grid;
  grid-template-columns: minmax(175px, 0.42fr) minmax(280px, 1fr);
  align-items: center;
  gap: 26px;
  padding: 19px 22px;
  background: #fffefa;
}

.tlx-card + .tlx-card {
  margin-top: 11px;
}

.tlx-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.range-wrap {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.range-value {
  justify-self: center;
  min-width: 52px;
  padding: 5px 9px;
  border: 1px solid #a6c4ba;
  border-radius: 9px;
  color: #125e58;
  background: var(--accent-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  text-align: center;
}

input[type="range"] {
  width: 100%;
  min-height: 32px;
  accent-color: var(--accent);
  cursor: pointer;
}

.range-anchors {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--dim);
  font-size: 0.79rem;
  font-weight: 650;
}

.range-anchors span:last-child {
  text-align: right;
}

.performance-warning {
  margin: 15px 0;
  padding: 13px 15px;
  border: 1px solid #c9ad58;
  border-radius: 13px;
  color: #644b12;
  background: var(--warning-soft);
  text-align: center;
  font-weight: 800;
}

.ranking-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
  align-items: center;
  gap: 11px 15px;
}

.ranking-grid label {
  color: #2d4a42;
}

.feedback-card.full,
.export-card.full {
  grid-column: 1 / -1;
}

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

.export-file-list {
  display: grid;
  gap: 9px;
  margin: 17px 0 0;
  padding: 0;
  list-style: none;
}

.export-file-list li {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #405d54;
  background: #f3f7f4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.83rem;
}

.export-help {
  margin-top: 18px;
  padding: 13px 14px;
  border: 1px solid #bfd0c9;
  border-radius: 12px;
  color: var(--muted);
  background: #f3f7f4;
}

.export-help > strong {
  display: block;
  margin-bottom: 5px;
  color: #29483f;
  font-size: 0.92rem;
}

.export-help .study-contact-list {
  margin-top: 5px;
}

.export-help .study-contact-list p {
  font-size: 0.86rem;
}

.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(32, 58, 52, 0.7);
  backdrop-filter: blur(10px);
}

.pause-overlay[hidden] {
  display: none;
}

.pause-dialog {
  width: min(540px, 100%);
  padding: clamp(26px, 5vw, 38px);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(25, 49, 42, 0.3);
}

.noscript-warning {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 32px;
  color: #ffffff;
  background: #29443d;
  font-size: 1.2rem;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 1050px) {
  .study-header {
    grid-template-columns: minmax(180px, auto) minmax(0, 1fr);
  }

  .header-progress {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }

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

  .task-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .study-app {
    padding: 10px;
  }

  .study-header {
    grid-template-columns: 1fr;
    gap: 13px;
    padding: 13px;
  }

  .header-actions,
  .header-progress {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
  }

  .header-progress {
    grid-template-columns: minmax(100px, auto) minmax(80px, 1fr);
  }

  .study-screen {
    min-height: 500px;
    padding: clamp(20px, 5vw, 32px);
    border-radius: 20px;
  }

  .welcome-grid,
  .setup-grid,
  .consent-key-info,
  .consent-grid,
  .feedback-grid,
  .export-grid,
  .task-sidebar,
  .likert-row {
    grid-template-columns: 1fr;
  }

  .tlx-intro,
  .task-header,
  .interaction-head {
    display: grid;
  }

  .condition-pill,
  .round-pill,
  .status-pill {
    width: fit-content;
    max-width: 100%;
    white-space: normal;
  }

  .tlx-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .message-bubble {
    max-width: 94%;
  }

  .consent-key-info {
    gap: 20px;
  }
}

@media (max-width: 560px) {
  .study-brand small {
    font-size: 0.74rem;
  }

  .header-actions {
    align-items: stretch;
  }

  .privacy-pill {
    white-space: normal;
  }

  .study-footer {
    display: grid;
  }

  .loading-card,
  .centered-panel {
    padding-inline: 4px;
  }

  h1 {
    font-size: clamp(1.8rem, 10vw, 2.45rem);
  }

  .button-row > button,
  .button-row > a {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .candidate-button {
    grid-template-columns: 38px minmax(0, 1fr);
    padding-inline: 11px;
  }

  .ranking-grid {
    grid-template-columns: minmax(0, 1fr) minmax(84px, auto);
  }

  .range-anchors {
    gap: 8px;
    font-size: 0.75rem;
  }

  .message-bubble {
    max-width: 100%;
  }

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

  .consent-grid {
    gap: 12px;
  }

  .consent-agreement .checkbox-field {
    padding: 11px;
  }

  .study-byline {
    margin-bottom: 18px;
    padding: 9px 11px;
  }

  .export-help {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #6e857c;
    --line-strong: #3e6257;
    --muted: #334f46;
    --dim: #3d574f;
  }

  .candidate-button.selected,
  .primary-button {
    border-width: 2px;
  }
}

@media (forced-colors: active) {
  .candidate-button.selected,
  .candidate-button.resign-option.selected {
    outline: 3px solid Highlight;
    outline-offset: 2px;
  }

  .interaction-card::before {
    background: CanvasText;
  }
}

@media print {
  @page {
    margin: 0.65in;
  }

  .study-header,
  .simulation-banner,
  .study-footer,
  .button-row,
  .key-guide {
    display: none !important;
  }

  html,
  body {
    min-width: 0;
    background: #ffffff !important;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.42;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .study-app {
    width: 100%;
    min-height: 0;
    display: block;
    padding: 0;
  }

  body,
  .study-screen,
  .info-card,
  .form-card,
  .goal-card,
  .conversation-card,
  .interaction-card {
    color: #111111;
    background: #ffffff;
    box-shadow: none;
  }

  .study-screen {
    min-height: 0;
    display: block;
    padding: 0;
    border: 0;
  }

  .consent-wrap {
    width: 100%;
    color: #111111;
  }

  .consent-wrap h1 {
    margin-bottom: 8pt;
    color: #111111;
    font-size: 24pt;
  }

  .consent-wrap h2 {
    color: #111111;
    font-size: 15pt;
  }

  .consent-wrap .eyebrow,
  .consent-wrap .lead,
  .consent-wrap p,
  .consent-wrap li,
  .consent-wrap dt,
  .consent-wrap dd {
    color: #111111;
  }

  .consent-wrap .lead {
    max-width: none;
    margin-bottom: 14pt;
    font-size: 11.5pt;
  }

  .consent-key-info {
    display: block;
    margin: 12pt 0;
    padding: 14pt;
    border: 1.5pt solid #555555;
    break-inside: avoid-page;
  }

  .consent-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6pt;
    margin-top: 10pt;
  }

  .consent-facts > div {
    padding: 7pt;
    border: 1px solid #888888;
    background: #ffffff;
    break-inside: avoid;
  }

  .consent-grid {
    display: block;
  }

  .consent-grid .info-card {
    margin: 0;
    padding: 12pt 0 10pt;
    border: 0;
    border-top: 1px solid #aaaaaa;
    border-radius: 0;
    break-inside: auto;
  }

  .consent-grid h2 {
    break-after: avoid;
  }

  .consent-list li {
    padding-left: 15pt;
    break-inside: avoid;
  }

  .consent-list li::before {
    width: 5pt;
    height: 5pt;
    background: #111111;
  }

  .consent-agreement {
    width: 100%;
    margin-top: 14pt;
    padding: 13pt;
    border: 1.5pt solid #555555;
    border-radius: 0;
    background: #ffffff;
    break-before: auto;
  }

  .consent-agreement form {
    margin-top: 8pt;
  }

  .consent-agreement .checkbox-field {
    display: block;
    margin: 0 !important;
    padding: 3pt 0 3pt 14pt;
    border: 0;
    background: #ffffff;
    break-inside: avoid;
  }

  .consent-agreement .checkbox-field input {
    display: none;
  }

  .consent-agreement .checkbox-field span::before {
    content: "• ";
    margin-left: -11pt;
  }

  .distribution-warning {
    margin: 10pt 0 12pt;
    padding: 10pt;
    border: 2pt solid #111111;
    border-radius: 0;
    color: #111111;
    background: #ffffff;
    box-shadow: none;
    break-inside: avoid-page;
  }

  .consent-wrap a {
    color: #111111;
    text-decoration: underline;
  }

  .study-byline,
  .export-help {
    color: #111111;
    background: #ffffff;
    box-shadow: none;
    break-inside: avoid;
  }

  .study-byline {
    margin: 6pt 0 12pt;
    padding: 6pt 8pt;
    border-left: 3pt solid #333333;
    border-radius: 0;
  }

  .study-contact-list p {
    color: #111111;
    break-inside: avoid;
  }

  .study-contact-list p + p {
    border-top-color: #aaaaaa;
  }

  .study-byline a,
  .study-contact-list a,
  .export-help a {
    color: #111111;
    text-decoration: underline;
  }

  .export-help {
    border: 1px solid #777777;
    border-radius: 0;
  }
}
