/* ---------- Font: Poppins, self-hosted (no third-party requests) ---------- */
@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/poppins-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/poppins-medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/poppins-semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #f4f6f8;
  --surface: #ffffff;
  --ink: #1c2430;
  --muted: #5d6673;
  --line: #dce1e7;
  --panel: #e2e7ed;
  --bar: #c3cad4;
  --button: #1c2430;
  --button-hover: #364152;

  --gutter: clamp(1.5rem, 6vw, 6rem);
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout: full-height split screen ---------- */
.landing {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 56rem) {
  .landing {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Left: text ---------- */
.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  text-align: center;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.75rem, 6vw, 5.25rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.intro h1 {
  width: 100%;
  font-size: clamp(2rem, 3.5vw, 3.25rem);
}

.lead {
  width: 100%;
  max-width: 30rem;
  margin: 0 0 2.5rem;
  color: var(--muted);
  font-size: clamp(1.125rem, 1.6vw, 1.3125rem);
}

.facts {
  width: 100%;
  max-width: 34rem;
  margin: 0 0 2.75rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* ---------- Button ---------- */
.button {
  align-self: center;
  padding: 1rem 1.75rem;
  border: 0;
  border-radius: 0.625rem;
  background: var(--button);
  color: #fff;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.button:hover {
  background: var(--button-hover);
}

.button:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 3px;
}

.button-agree {
  background: #167342;
}

.button-agree:hover {
  background: #105d35;
}

.button-deny {
  background: #b42318;
}

.button-deny:hover {
  background: #8f1d14;
}

.consent-page {
  min-height: 100vh;
  padding: clamp(4.5rem, 8vw, 6rem) clamp(1rem, 4vw, 2rem) 2rem;
}

.consent-card {
  width: min(100%, 50rem);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
}

.consent-card h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}

.consent-content h2 {
  margin: 1.75rem 0 0.4rem;
  font-size: 1.15rem;
}

.consent-content p {
  margin: 0 0 1rem;
}

.consent-content ul {
  display: grid;
  gap: 0.7rem;
  margin: 0 0 1.25rem;
  padding-left: 1.4rem;
}

.consent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.consent-actions .button {
  align-self: auto;
}

/* ---------- Travel screening ---------- */
.travel-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
}

.travel-card,
.travel-form-wrap {
  width: min(100%, 42rem);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: 0 1.5rem 4rem rgb(28 36 48 / 7%);
}

.travel-intro {
  text-align: center;
}

.role-instructions-card {
  width: min(100%, 48rem);
  text-align: left;
}

/* Center only the ready-state content, leaving the instruction page left-aligned. */
.role-instructions-card--waiting {
  text-align: center;
}

.role-instructions-card--waiting .travel-lead {
  margin-right: auto;
  margin-left: auto;
}

.role-instructions-waiting__progress {
  margin: 1.5rem 0 1rem;
}

.role-instructions-waiting__progress .matching-ring {
  margin-bottom: 0.5rem;
}

.role-instructions-card h2 {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.15rem;
}

.role-instructions-steps {
  display: grid;
  gap: 1rem;
  margin: 0 0 1.5rem;
  padding-left: 1.5rem;
}

.role-instructions-steps blockquote {
  margin: 0.75rem 0 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--line);
  background: var(--paper);
}

.role-instructions-actions {
  display: flex;
  justify-content: center;
}

/* Make the shared countdown replace all prior dialogue content in the chat area. */
.transition-panel--countdown {
  gap: 0.75rem;
  padding: 2rem 1.25rem;
  text-align: center;
}

.transition-panel--countdown .transition-message {
  margin: 0;
}

.transition-panel--countdown .transition-countdown {
  font-variant-numeric: tabular-nums;
}

.transition-panel--countdown #transition-ring {
  display: none;
}

.travel-card h1,
.travel-form-wrap h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}

.travel-lead {
  max-width: 46rem;
  margin: 0 0 0.75rem;
  color: var(--ink);
  font-size: 1.125rem;
}

.travel-supporting {
  margin: 0 0 2rem;
  color: var(--muted);
}

/* ---------- Matching: actual stages, not estimated progress ---------- */
.matching-progress {
  margin: 2rem 0 1.5rem;
}

.matching-ring {
  flex: 0 0 3rem;
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1.5rem;
  border: 3px solid var(--line);
  border-top-color: var(--muted);
  border-radius: 50%;
}

.matching-ring--animated {
  /* Turn the ring around its vertical axis so it narrows into an oval like a spinning disk. */
  animation: matching-disk-spin 2.4s linear infinite;
}

.matching-motion-toggle {
  min-height: 2.75rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.matching-motion-toggle:hover {
  color: var(--ink);
}

.matching-motion-toggle:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 3px;
}

@keyframes matching-disk-spin {
  from { transform: perspective(4rem) rotateY(0deg); }
  to { transform: perspective(4rem) rotateY(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .matching-ring--animated {
    animation: none;
  }

  .matching-motion-toggle {
    display: none;
  }
}

.travel-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-width: 9rem;
}

.travel-page--form {
  display: block;
}

.travel-form-wrap {
  width: min(100%, 70rem);
  padding: clamp(1.25rem, 4vw, 2.75rem);
}

.travel-form-wrap > .travel-lead {
  margin-bottom: 1.75rem;
  color: var(--muted);
  font-size: 1rem;
}

.travel-progress {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--paper);
}

.travel-progress__labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
  font-size: 0.875rem;
}

.travel-progress__labels strong {
  font-weight: 600;
}

.travel-progress__track {
  overflow: hidden;
  height: 0.45rem;
  border-radius: 1rem;
  background: #dce1e7;
}

.travel-progress__track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #17653e;
  transition: width 0.2s ease;
}

.travel-duplicate-warning,
.travel-error-summary {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid #e6aaa6;
  border-radius: 0.625rem;
  background: #fff3f2;
  color: #8f1d14;
  font-size: 0.9rem;
}

.travel-error-summary p {
  margin: 0 0 0.35rem;
}

.travel-error-summary ul {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding-left: 1.25rem;
}

.travel-duplicate-warning[hidden] {
  display: none;
}

.city-card {
  min-width: 0;
  margin: 1rem 0;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  background: #fff;
}

.city-card h2 {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.travel-fields {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.travel-fields--city {
  grid-template-columns: minmax(0, 1fr) minmax(12rem, 0.7fr);
}

.travel-fields--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.travel-fields--bottom {
  grid-template-columns: minmax(12rem, 0.7fr) minmax(0, 1.3fr);
  align-items: start;
}

.travel-field {
  min-width: 0;
}

.travel-field > label,
.travel-field__label,
.familiarity-field > legend {
  display: block;
  margin: 0 0 0.4rem;
  padding: 0;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
}

.travel-field input:not([type="radio"]),
.travel-field select,
.travel-field textarea {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #b9c1cb;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}

.travel-field textarea {
  min-height: 7rem;
  resize: vertical;
}

.feedback-text-field {
  margin-top: 1.25rem;
}

.feedback-field__help {
  margin: -0.15rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.travel-field input[aria-invalid="true"],
.travel-field select[aria-invalid="true"] {
  border-color: #b42318;
}

.travel-date-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.travel-date-selects select:disabled {
  background: var(--paper);
  color: var(--muted);
}

.travel-field input:focus-visible,
.travel-field select:focus-visible,
.travel-field textarea:focus-visible,
.familiarity-option input:focus-visible + span {
  outline: 3px solid #7da991;
  outline-offset: 2px;
}

.field-error {
  display: block;
  margin-top: 0.35rem;
  color: #8f1d14;
  font-size: 0.8rem;
}

.field-error:empty {
  display: none;
}

.familiarity-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.familiarity-options {
  display: grid;
  grid-template-columns: repeat(7, minmax(2rem, 1fr));
  gap: 0.4rem;
}

.visit-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.familiarity-option {
  cursor: pointer;
}

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

.familiarity-option span {
  display: grid;
  min-height: 2.6rem;
  place-items: center;
  border: 1px solid #b9c1cb;
  border-radius: 0.5rem;
  background: #fff;
  font-size: 0.9rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.familiarity-option input:checked + span {
  border-color: #17653e;
  background: #e7f1eb;
  color: #105235;
  font-weight: 600;
}

.familiarity-help {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.travel-form__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.travel-exit {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.travel-exit:hover {
  color: var(--ink);
}

.travel-form__footer .button {
  align-self: auto;
}

.screened-out {
  text-align: center;
}

.screened-out .travel-lead {
  margin-right: auto;
  margin-left: auto;
}

@media (max-width: 52rem) {
  .travel-fields--three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 38rem) {
  .travel-page {
    padding: 0.75rem;
  }

  .travel-card,
  .travel-form-wrap {
    padding: 1.25rem;
    border-radius: 0.75rem;
  }

  .travel-fields--city,
  .travel-fields--three,
  .travel-fields--bottom {
    grid-template-columns: 1fr;
  }

  .travel-form__footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .travel-form__footer .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .travel-progress__track span,
  .familiarity-option span {
    transition: none;
  }
}

/* ---------- Right: conversation panel ---------- */
.preview {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: var(--gutter);
  /* keep the conversation a readable column on very wide screens */
  padding-inline: max(var(--gutter), (100% - 32rem) / 2);
  background: var(--panel);
}

.bubble {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 70%;
  padding: 1.15rem 1.25rem;
  border-radius: 1.1rem;
  opacity: 0;
  animation: appear 0.4s ease-out forwards;
}

.bubble span {
  display: block;
  height: 0.6rem;
  border-radius: 1rem;
}

.bubble span:last-child:not(:first-child) {
  width: 60%;
}

/* Interviewer: left, white */
.bubble.asks {
  align-self: flex-start;
  background: var(--surface);
  border-bottom-left-radius: 0.3rem;
}

.bubble.asks span {
  background: var(--bar);
}

/* Interviewee: right, dark */
.bubble.answers {
  align-self: flex-end;
  width: 80%;
  background: var(--ink);
  border-bottom-right-radius: 0.3rem;
}

.bubble.answers span {
  background: #5a6578;
}

/* Bubbles arrive one after another, like a conversation */
.bubble:nth-child(1) { animation-delay: 0.2s; }
.bubble:nth-child(2) { animation-delay: 0.7s; }
.bubble:nth-child(3) { animation-delay: 1.2s; }
.bubble:nth-child(4) { animation-delay: 1.7s; }

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bubble {
    opacity: 1;
    animation: none;
  }
}

/* ---------- Phones: panel becomes a band above the text ---------- */
@media (max-width: 55.99rem) {
  .preview {
    order: -1;
    padding: 2rem 1.5rem;
  }

  .bubble:nth-child(n + 3) {
    display: none;
  }
}

/* ---------- Local dialogue prototype ---------- */
.chat-page {
  width: min(100%, 56rem);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-direction: column;
}

.role-announcement {
  align-self: flex-start;
  margin-bottom: 1rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
}

.role-announcement strong {
  color: var(--ink);
  font-weight: 600;
}

.room-page {
  width: min(100%, 52rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-direction: column;
}

.room-card {
  width: min(100%, 34rem);
  margin: auto;
}

.room-eyebrow {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.room-card h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.03em;
}

.room-intro {
  margin: 0 0 2rem;
  color: var(--muted);
}

.room-create {
  width: 100%;
}

.room-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.room-divider::before,
.room-divider::after {
  flex: 1;
  border-top: 1px solid var(--line);
  content: "";
}

.room-join {
  display: flex;
  gap: 0.5rem;
}

.room-join input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-transform: uppercase;
}

.room-code-display {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.room-status {
  min-height: 1.5em;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.room-code-display strong {
  color: var(--ink);
  font-size: 1.1rem;
  letter-spacing: 0.12em;
}

.chat-notice {
  margin: -0.25rem 0 1rem;
}

.room-card button:disabled,
.chat-send:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}

.question-progress {
  margin: 0;
  padding: 0.75rem 1.25rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 72%, var(--surface));
}

/* Give both progress indicators equal space and matching alignment. */
.progress-pair {
  display: flex;
  gap: 1.5rem;
}

.progress-pair__item {
  flex: 1;
  min-width: 0;
}

.question-progress__labels {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
}

.question-counter,
.question-progress__note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.question-counter {
  color: var(--ink);
  font-weight: 600;
}

.question-progress__note {
  text-align: right;
}

.question-progress__track {
  height: 0.35rem;
  overflow: hidden;
  border-radius: 1rem;
  background: #dce1e7;
}

.question-progress__track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #17653e;
  transition: width 0.2s ease;
}

/* Stack the indicators on narrow screens so their labels remain readable. */
@media (max-width: 38rem) {
  .progress-pair {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* ---------- Shared transition and optional interviewee maze ---------- */
.transition-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem;
  text-align: center;
}

.transition-message {
  max-width: 34rem;
  margin: 0;
  color: var(--ink);
}

.transition-countdown {
  color: var(--ink);
  font-size: clamp(2rem, 8vw, 3.25rem);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

#transition-ring {
  /* Keep the ring at its intended size and separate it from the message and maze. */
  margin-block: 1rem;
}

.transition-maze {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  width: min(100%, 22rem);
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
}

.transition-maze h2,
.transition-maze p {
  margin: 0;
}

.transition-maze h2 {
  color: var(--ink);
  font-size: 1rem;
}

.transition-maze #maze-instructions {
  color: var(--muted);
  font-size: 0.875rem;
}

.maze-board {
  display: grid;
  grid-template-columns: repeat(9, clamp(1.35rem, 6vw, 2rem));
  width: max-content;
  border: 2px solid var(--line);
  outline: none;
}

.maze-board:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 3px;
}

.maze-cell {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--surface);
}

.maze-cell--wall {
  background: var(--panel);
}

.maze-cell--start::after,
.maze-cell--exit::after,
.maze-cell--player::after {
  position: absolute;
  inset: 23%;
  border-radius: 50%;
  content: "";
}

.maze-cell--start::after {
  border: 2px solid var(--muted);
}

.maze-cell--exit::after {
  background: #17653e;
}

.maze-cell--player::after {
  background: var(--button);
}

.maze-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(3.25rem, auto));
  grid-template-areas: ". up ." "left down right";
  gap: 0.35rem;
}

.maze-control {
  min-height: 2.75rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.maze-control[data-maze-direction="up"] { grid-area: up; }
.maze-control[data-maze-direction="left"] { grid-area: left; }
.maze-control[data-maze-direction="down"] { grid-area: down; }
.maze-control[data-maze-direction="right"] { grid-area: right; }

.maze-control:hover {
  background: var(--paper);
}

.maze-control:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 2px;
}

.maze-control:active {
  background: var(--panel);
}

@media (prefers-reduced-motion: reduce) {
  .question-progress__track span {
    transition: none;
  }
}

.chat-messages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  overflow-y: auto;
  padding: 1.25rem;
}

.chat-empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.chat-message {
  max-width: min(80%, 32rem);
  align-self: flex-end;
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 1rem 1rem 0.25rem 1rem;
  background: var(--ink);
  color: var(--surface);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-message--remote {
  align-self: flex-start;
  border-radius: 1rem 1rem 1rem 0.25rem;
  background: var(--panel);
  color: var(--ink);
}

.chat-typing {
  display: flex;
  gap: 0.3rem;
  min-height: 0.75rem;
  margin: 0.2rem 0;
  padding-left: 1.5rem;
  align-items: center;
}

.chat-typing-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.chat-typing-dot:nth-child(3) {
  animation-delay: 0.15s;
}

.chat-typing-dot:nth-child(4) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: none;
  }
  30% {
    opacity: 1;
    transform: translateY(-0.2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing-dot {
    animation: none;
  }
}

.chat-composer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.chat-composer > input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.chat-composer > input:focus-visible,
.chat-send:focus-visible {
  outline: 3px solid var(--button-hover);
  outline-offset: 3px;
}

.judgement-form {
  display: grid;
  width: 100%;
  gap: 0.75rem;
  align-items: stretch;
}

.judgement-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 1rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.judgement-fields legend {
  margin-bottom: 0.25rem;
  padding: 0;
  color: var(--ink);
  font-weight: 600;
}

/* Keep each staged prompt and its controls grouped vertically. */
.judgement-step {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.judgement-instruction {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.judgement-stage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.judgement-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.judgement-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

/* Match the True/False control height to the adjacent shared-style Submit button. */
.judgement-choice,
.judgement-stage-row > .chat-send {
  min-height: 3.6rem;
}

.judgement-true:has(input:checked) {
  border-color: #17653e;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

.judgement-true {
  border-color: #167342;
  background: #167342;
  color: #ffffff;
}

.judgement-false:has(input:checked) {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

.judgement-false {
  border-color: #b42318;
  background: #b42318;
  color: #ffffff;
}

.judgement-true:hover {
  background: #105d35;
}

.judgement-false:hover {
  background: #8f1d14;
}

.judgement-choice input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--button);
}

.judgement-choice:focus-within,
.judgement-confidence input:focus-visible {
  outline: 3px solid var(--button-hover);
  outline-offset: 2px;
}

.judgement-confidence {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: left;
}

.judgement-confidence input {
  /* Keep the native range control keyboard-operable while making its touch target comfortable. */
  -webkit-appearance: none;
  appearance: none;
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  height: 2.75rem;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}

.judgement-confidence output {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Match the range track across WebKit browsers and Firefox. */
.judgement-confidence input::-webkit-slider-runnable-track {
  height: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
}

.judgement-confidence input::-moz-range-track {
  height: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
}

.judgement-confidence input::-moz-range-progress {
  height: 0.5rem;
  border-radius: 1rem;
  background: var(--button);
}

/* Give the slider thumb a high-contrast, touch-friendly target in WebKit browsers. */
.judgement-confidence input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  box-sizing: border-box;
  margin-top: -0.375rem;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--button);
}

/* Match the WebKit thumb dimensions and contrast in Firefox. */
.judgement-confidence input::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  box-sizing: border-box;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--button);
}

.judgement-confidence input:hover::-webkit-slider-thumb {
  background: var(--button-hover);
}

.judgement-confidence input:hover::-moz-range-thumb {
  background: var(--button-hover);
}

.judgement-status {
  display: flex;
  align-items: center;
  min-height: 3.6rem;
  margin: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--muted);
  border-radius: 0.625rem;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  text-align: left;
}

.judgement-feedback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
}

.judgement-status--correct {
  border-color: #9dc9aa;
  border-left-color: #17653e;
  background: #edf7ef;
  color: #174b2b;
}

.judgement-status--incorrect {
  border-color: #e2b2aa;
  border-left-color: #a52a1c;
  background: #fff1ef;
  color: #762016;
}

.judgement-continue {
  align-self: stretch;
  min-height: 3.6rem;
  justify-self: end;
}

@media (max-width: 40rem) {
  .judgement-stage-row {
    gap: 0.5rem;
  }

  .judgement-stage-row > .chat-send,
  .judgement-continue {
    width: auto;
    justify-self: end;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 40rem) {
  .chat-page {
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    padding: 1rem;
  }

  .room-join {
    flex-direction: column;
  }
}

[hidden] {
  display: none !important;
}