:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf5;
  --muted: #8b9bb4;
  --accent: #5b8def;
  --accent-hover: #4a7de0;
  --success: #3ecf8e;
  --warning: #f5a623;
  --danger: #ef6461;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(ellipse at top, #1a2744 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

header {
  margin-bottom: 2rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
}

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

header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.field .hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(91, 141, 239, 0.45);
  border-color: var(--accent);
}

.voice-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.voice-row textarea {
  flex: 1 1 100%;
}

.behavior-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.behavior-section h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.behavior-intro {
  margin: 0 0 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.2rem;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #2c3b52;
}

.btn-secondary.recording {
  background: rgba(239, 100, 97, 0.15);
  border-color: var(--danger);
  color: #ffb4b2;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.status {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.status.info {
  background: rgba(91, 141, 239, 0.12);
  border: 1px solid rgba(91, 141, 239, 0.35);
}

.status.error {
  background: rgba(239, 100, 97, 0.12);
  border: 1px solid rgba(239, 100, 97, 0.35);
}

.status.success {
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid rgba(62, 207, 142, 0.35);
}

.status.hidden {
  display: none;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.score-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.score-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
}

.score-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.score-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  color: var(--text);
  text-transform: none;
}

.score-tagline {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.score-value-wrap {
  text-align: right;
  flex-shrink: 0;
}

.score-summary {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0.92;
}

.score-details {
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}

.score-details summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.score-details summary::-webkit-details-marker {
  display: none;
}

.score-details summary::before {
  content: "▸ ";
}

.score-details[open] summary::before {
  content: "▾ ";
}

.score-details-body {
  margin-top: 0.85rem;
}

.score-details-body h4 {
  margin: 1rem 0 0.5rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.score-details-body h4:first-of-type {
  margin-top: 0.35rem;
}

.input-list,
.breakdown-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.input-list li {
  padding: 0.3rem 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.input-list li::before {
  content: "· ";
  color: var(--accent);
}

.breakdown-row {
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(45, 58, 79, 0.6);
}

.breakdown-row:last-child {
  border-bottom: none;
}

.breakdown-row-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  font-size: 0.88rem;
}

.breakdown-row.missing .breakdown-row-head strong {
  color: var(--muted);
}

.breakdown-weight {
  color: var(--muted);
  font-size: 0.82rem;
}

.breakdown-signals {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.breakdown-intro {
  margin: 0 0 0.65rem;
  line-height: 1.45;
}

.signal-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.signal-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  border-left-width: 3px;
}

.signal-chip.signal-band-strong {
  border-left-color: var(--success);
}

.signal-chip.signal-band-moderate {
  border-left-color: var(--warning);
}

.signal-chip.signal-band-low {
  border-left-color: #e07070;
}

.signal-chip-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.signal-chip-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.signal-chip-score {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.signal-chip-max {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.signal-chip-band {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--accent);
}

.signal-chip-detail {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text);
}

.signal-chip-hint {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.score-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.score-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.cohort-benchmark-banner {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
}

.cohort-benchmark-banner.hidden {
  display: none;
}

.cohort-benchmark-banner strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.92rem;
}

.cohort-benchmark-banner p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.cohort-benchmark-peer {
  margin-top: 0.45rem !important;
  color: var(--text) !important;
  font-weight: 500;
}

.cohort-benchmark-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.cohort-benchmark-tag {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.section-title {
  margin: 1.5rem 0 0.75rem;
  font-size: 1rem;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.narrative {
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.narrative-sections {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.narrative-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.narrative-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.narrative-block ul {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.narrative-block li {
  margin-bottom: 0.35rem;
}

.crisis-notice {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: rgba(220, 80, 80, 0.12);
  border: 1px solid rgba(220, 80, 80, 0.35);
  color: #f0a0a0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.therapist-recs {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.test-recs {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.test-heading {
  margin: 0;
  font-size: 0.95rem;
}

.test-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.test-card-body {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.test-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  background: rgba(99, 179, 237, 0.12);
  border: 1px solid rgba(99, 179, 237, 0.25);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.test-info {
  flex: 1;
  min-width: 0;
}

.test-name-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.test-name {
  font-size: 0.95rem;
  color: var(--text);
}

.test-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.test-concern {
  font-size: 0.82rem;
  color: var(--accent);
  margin-top: 0.3rem;
}

.test-reason {
  font-size: 0.86rem;
  color: var(--text);
  margin: 0.45rem 0 0;
  line-height: 1.45;
}

.test-improvement {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  line-height: 1.45;
}

.test-impact {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--success);
}

.rec-explore-action {
  margin-top: 0.35rem;
}

.rec-explore-btn {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  text-decoration: none;
}

.therapist-heading {
  margin: 0;
  font-size: 0.95rem;
}

.therapist-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  overflow: hidden;
}

.therapist-card-body {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.therapist-avatar-wrap {
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
}

.therapist-avatar {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 56px;
  max-height: 56px;
  object-fit: cover;
  object-position: center top;
}

.therapist-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
}

.therapist-info {
  flex: 1;
  min-width: 0;
}

.therapist-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.therapist-name {
  font-size: 0.95rem;
  color: var(--text);
}

.therapist-rating {
  font-size: 0.78rem;
  color: var(--warning);
  white-space: nowrap;
}

.therapist-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.45;
}

.therapist-concern {
  font-size: 0.82rem;
  color: var(--accent);
  margin-top: 0.3rem;
}

.therapist-cta {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: var(--success);
}

.disclaimer {
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.25);
  color: #f0c878;
  font-size: 0.85rem;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@media (max-width: 560px) {
  .container {
    padding: 1.25rem 1rem 2rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .score-card-top {
    flex-direction: column;
  }

  .score-value-wrap {
    text-align: left;
  }

  header h1 {
    font-size: 1.45rem;
  }
}
