:root {
  --navy: #0f3656;
  --text: #243947;
  --muted: #5a7182;
  --line: rgba(15, 54, 86, 0.14);
  --fill: #ffffff;
  --page: #f3f7fa;
  --angry: #9b2226;
  --sad: #e07a5f;
  --neutral: #e09a3e;
  --smile: #d4a017;
  --happy: #3d9b5c;
  --radius: 12px;
  --font: "Source Sans 3", sans-serif;
  --space: 1.25rem;
  --max: 26.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, #e7eef4 0%, var(--page) 42%, #eef3f7 100%);
}

.page {
  width: min(100% - (var(--space) * 2), var(--max));
  margin: 0 auto;
  padding: 1.5rem 0 calc(3rem + env(safe-area-inset-bottom, 0px));
}

.brand {
  display: flex;
  justify-content: center;
  margin: 0 0 1.75rem;
}

.brand__logo {
  display: block;
  width: min(100%, 13.5rem);
  height: auto;
}

.intro {
  margin-bottom: 1.75rem;
}

.intro h1 {
  margin: 0 0 0.75rem;
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--navy);
  text-wrap: balance;
}

.intro__lead,
.section-note,
.question__hint,
.audio-status,
.upload-status,
.form-status {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted);
}

.intro__lead {
  color: var(--text);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 2.15rem;
}

.questions {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.question__label,
.section-heading,
.follow-up__fieldset legend,
.field-label {
  margin: 0 0 0.65rem;
  font-family: var(--font);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--navy);
}

.question__hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.875rem;
}

.section-note {
  margin: -0.25rem 0 1rem;
}

.questions .section-note {
  margin: 0;
}

.field-label {
  display: block;
  margin: 1.15rem 0 0.4rem;
  font-size: 0.875rem;
}

/* Emoji slider */
.emoji-slider {
  --value: 3;
  width: 100%;
  touch-action: none;
  user-select: none;
  outline: none;
  -webkit-user-select: none;
}

.emoji-slider:focus-visible .emoji-slider__track {
  outline: 2px solid var(--navy);
  outline-offset: 4px;
}

.emoji-slider__faces {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.emoji-slider__face {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  aspect-ratio: 1;
  max-width: 3.25rem;
  justify-self: center;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.emoji-slider__face svg {
  display: block;
  width: 100%;
  height: 100%;
}

.emoji-slider__face[data-score="1"] { color: var(--angry); }
.emoji-slider__face[data-score="2"] { color: var(--sad); }
.emoji-slider__face[data-score="3"] { color: var(--neutral); }
.emoji-slider__face[data-score="4"] { color: var(--smile); }
.emoji-slider__face[data-score="5"] { color: var(--happy); }

/* Unanswered: even, muted — no face looks selected */
.emoji-slider:not([data-answered="true"]) .emoji-slider__face {
  opacity: 0.45;
}

.emoji-slider:not([data-answered="true"]) .emoji-slider__track {
  opacity: 0.55;
}

.emoji-slider:not([data-answered="true"]) .emoji-slider__thumb {
  opacity: 0.45;
  box-shadow: none;
  border-color: rgba(15, 54, 86, 0.18);
}

/* Answered: one clear selection */
.emoji-slider[data-answered="true"] .emoji-slider__face {
  opacity: 0.35;
}

.emoji-slider[data-answered="true"] .emoji-slider__face[aria-pressed="true"] {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .emoji-slider__face:hover {
    opacity: 1;
  }

  .emoji-slider[data-answered="true"] .emoji-slider__face[aria-pressed="true"] {
    transform: scale(1.05);
  }
}

.emoji-slider__track-wrap {
  position: relative;
  padding: 0.6rem 0;
}

.emoji-slider__track {
  height: 0.7rem;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  transition: opacity 0.15s ease;
}

.emoji-slider__seg:nth-child(1) { background: var(--angry); }
.emoji-slider__seg:nth-child(2) { background: var(--sad); }
.emoji-slider__seg:nth-child(3) { background: var(--neutral); }
.emoji-slider__seg:nth-child(4) { background: var(--smile); }
.emoji-slider__seg:nth-child(5) { background: var(--happy); }

.emoji-slider__thumb {
  position: absolute;
  top: 50%;
  left: calc((var(--value) - 0.5) / 5 * 100%);
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(15, 54, 86, 0.12);
  box-shadow: 0 1px 2px rgba(15, 54, 86, 0.16);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.14s ease, opacity 0.15s ease;
}

.emoji-slider.is-dragging .emoji-slider__thumb {
  transition: none;
}

.emoji-slider__status {
  margin: 0.15rem 0 0;
  min-height: 1.2em;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--muted);
}

/* Fields */
textarea,
input[type="text"] {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--fill);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.45;
  transition: border-color 0.15s ease;
}

textarea {
  resize: vertical;
  min-height: 7.5rem;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--navy);
}

textarea::placeholder,
input::placeholder {
  color: #8a9eae;
}

.upload-block {
  position: relative;
}

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

.upload-controls,
.audio-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
}

.upload-status {
  flex: 1 1 100%;
  min-height: 1.25em;
}

.upload-preview {
  display: block;
  width: 100%;
  max-height: 14rem;
  margin-top: 0.75rem;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--fill);
}

.upload-preview[hidden] {
  display: none;
}

.audio-status,
.upload-status {
  flex: 1 1 100%;
  min-height: 1.25em;
}

.upload-block,
.audio-block {
  padding-top: 0.15rem;
}

.player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.35rem 0.9rem 0.35rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--fill);
}

.player[hidden] {
  display: none;
}

.player__play {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  line-height: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.player__play:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.player__icon {
  display: none;
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
  flex-shrink: 0;
}

.player__icon--play {
  display: block;
  transform: translateX(0.12rem);
}

.player__icon--pause {
  display: none;
}

.player.is-playing .player__icon--play {
  display: none;
}

.player.is-playing .player__icon--pause {
  display: block;
  transform: none;
}

.player__time {
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 2.1rem;
  line-height: 1;
}

.player__seek {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 0.35rem;
  margin: 0;
  background: rgba(15, 54, 86, 0.14);
  border-radius: 999px;
  cursor: pointer;
}

.player__seek::-webkit-slider-runnable-track {
  height: 0.35rem;
  background: transparent;
  border: 0;
}

.player__seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0.85rem;
  height: 0.85rem;
  margin-top: -0.25rem;
  border: 0;
  border-radius: 50%;
  background: var(--navy);
}

.player__seek::-moz-range-track {
  height: 0.28rem;
  background: rgba(15, 54, 86, 0.14);
  border: 0;
  border-radius: 999px;
}

.player__seek::-moz-range-thumb {
  width: 0.9rem;
  height: 0.9rem;
  border: 0;
  border-radius: 50%;
  background: var(--navy);
}

.secondary-btn.is-recording {
  border-color: var(--angry);
  color: var(--angry);
  animation: record-pulse 1.5s ease-in-out infinite;
}

@keyframes record-pulse {
  50% {
    background: #fff5f3;
  }
}

/* Follow-up */
.follow-up__fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.choice-row {
  display: flex;
  gap: 0.65rem;
}

.choice {
  position: relative;
  flex: 1;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
}

.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--fill);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.choice input:focus-visible + span {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

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

.follow-up__details {
  margin-top: 1rem;
}

.follow-up__details[hidden] {
  display: none;
}

/* Buttons */
.submit-btn,
.secondary-btn,
.text-btn {
  font-family: var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.submit-btn {
  appearance: none;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  min-height: 3rem;
  background: var(--navy);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

.submit-btn:active {
  background: #164868;
}

.submit-btn:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 3px;
}

.submit-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.secondary-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  min-height: 2.75rem;
  background: var(--fill);
  color: var(--navy);
  font-size: 0.9375rem;
  font-weight: 600;
}

.secondary-btn:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.text-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0.25rem 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.submit-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-status {
  min-height: 1.35em;
}

.form-status.is-success {
  color: var(--happy);
  font-weight: 600;
}

.form-status.is-error {
  color: var(--angry);
  font-weight: 600;
}

@media (min-width: 480px) {
  :root {
    --max: 32rem;
    --space: 1.5rem;
  }

  .brand__logo {
    width: 15rem;
  }

  .intro h1 {
    font-size: 1.625rem;
  }

  .submit-btn {
    width: auto;
    min-width: 11rem;
  }
}

@media (min-width: 768px) {
  :root {
    --max: 38rem;
  }

  .page {
    padding-top: 2.25rem;
  }

  .emoji-slider__face {
    max-width: 3.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .emoji-slider__face,
  .emoji-slider__thumb,
  .choice span,
  .submit-btn,
  .secondary-btn.is-recording {
    transition: none !important;
    animation: none !important;
  }
}
