:root {
  --ink: #202824;
  --muted: #657069;
  --line: #d9dfdb;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --primary: #176b5b;
  --primary-dark: #0f574a;
  --primary-soft: #e5f1ed;
  --accent: #b46b2c;
  --accent-soft: #f7eee4;
  --danger: #a23d36;
  --client: #315f78;
  --therapist: #6c4f86;
  --shadow: 0 12px 28px rgba(31, 46, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
select,
textarea,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
select,
input[type="radio"] + span {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
.transcript-body:focus-visible,
input[type="radio"]:focus-visible + span {
  outline: 3px solid rgba(23, 107, 91, 0.28);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.brand-lockup,
.header-context,
.rating-actions,
.review-actions,
.completion-actions {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.brand-name,
.brand-subtitle,
.eyebrow,
.panel-kicker,
.save-status,
.answered-count,
.privacy-copy,
.validation-message,
.app-footer p {
  margin: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.header-context {
  gap: 14px;
}

.rater-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.rater-badge {
  min-height: 32px;
  padding: 5px 12px;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.text-button,
.danger-text-button {
  padding: 4px;
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.danger-text-button {
  margin-top: 24px;
  color: var(--danger);
}

main {
  min-height: calc(100vh - 118px);
}

.start-screen,
.review-screen,
.complete-screen {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
}

.start-screen {
  display: grid;
  min-height: calc(100vh - 118px);
  align-items: center;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  gap: clamp(40px, 8vw, 110px);
  padding: 64px 0 80px;
}

.start-copy {
  max-width: 680px;
}

.eyebrow,
.panel-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 720;
  line-height: 1.15;
}

h1 {
  margin-top: 12px;
  font-size: clamp(34px, 5vw, 54px);
  max-width: 760px;
}

h2 {
  margin-top: 4px;
  font-size: 22px;
}

.lede {
  max-width: 640px;
  margin: 22px 0 0;
  color: #4e5c54;
  font-size: 19px;
}

.start-form {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.start-form label,
.note-field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid #b9c3bd;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
}

select {
  min-height: 48px;
  padding: 10px 38px 10px 12px;
}

.privacy-copy {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 5px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.primary-button:disabled {
  border-color: #b8c1bc;
  color: #6f7973;
  background: #dce2de;
  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid #aeb9b2;
  color: var(--ink);
  background: #fff;
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rating-screen {
  padding: 18px clamp(16px, 2.5vw, 36px) 28px;
}

.workflow-bar {
  display: flex;
  width: min(1540px, 100%);
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
  gap: 24px;
}

.progress-track {
  display: grid;
  width: min(350px, 72vw);
  height: 5px;
  margin-top: 8px;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.progress-segment {
  border-radius: 2px;
  background: #cfd7d2;
}

.progress-segment.complete {
  background: var(--primary);
}

.progress-segment.current {
  background: var(--accent);
}

.save-status,
.answered-count {
  color: var(--muted);
  font-size: 13px;
}

.rating-workspace {
  display: grid;
  width: min(1540px, 100%);
  height: calc(100vh - 162px);
  min-height: 650px;
  margin: 0 auto;
  grid-template-columns: minmax(0, 1.08fr) minmax(500px, 0.92fr);
  gap: 16px;
}

.transcript-panel,
.scale-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(31, 46, 39, 0.05);
}

.transcript-panel,
.scale-panel {
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  min-height: 78px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}

.transcript-body,
.scale-panel form {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.transcript-body {
  flex: 1 1 auto;
  padding: 22px clamp(18px, 3vw, 38px) 54px;
  scroll-behavior: smooth;
}

.turn {
  display: grid;
  max-width: 92%;
  margin-bottom: 22px;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
}

.turn.client {
  margin-left: auto;
}

.speaker-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.therapist .speaker-mark {
  background: var(--therapist);
}

.client .speaker-mark {
  background: var(--client);
}

.turn-content {
  min-width: 0;
}

.speaker-name {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.turn-text {
  margin: 0;
  overflow-wrap: anywhere;
  color: #28332d;
  font-size: 16px;
  line-height: 1.62;
}

.scale-heading {
  min-height: 78px;
}

.anchor-legend {
  display: grid;
  flex: 0 0 auto;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #fafbf9;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.anchor-legend span {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  font-size: 11px;
}

.anchor-legend b {
  color: var(--ink);
}

.scale-panel form {
  flex: 1 1 auto;
}

.scale-item {
  margin: 0;
  padding: 17px 20px 19px;
  border: 0;
  border-bottom: 1px solid #e5e9e6;
}

.scale-item.missing {
  background: #fff7f3;
}

.scale-item legend {
  display: grid;
  width: 100%;
  margin-bottom: 12px;
  padding: 0;
  color: #27312c;
  font-size: 14px;
  font-weight: 600;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 7px;
  line-height: 1.48;
}

.item-number {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 12px;
  vertical-align: top;
}

.item-text {
  min-width: 0;
}

.item-subscale {
  margin-top: 2px;
  padding: 2px 7px;
  border: 1px solid #cad9d3;
  border-radius: 999px;
  color: var(--primary-dark);
  background: #f4f8f6;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.rating-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(52px, 1fr));
  gap: 7px;
}

.rating-option {
  position: relative;
  min-width: 0;
}

.rating-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.rating-option span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid #bac4be;
  border-radius: 4px;
  color: #4d5a53;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.rating-option input:checked + span {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.rating-option:hover span {
  border-color: var(--primary);
}

.note-field {
  padding: 20px;
}

.note-field label {
  font-size: 14px;
}

.note-field label span {
  color: var(--muted);
  font-weight: 400;
}

textarea {
  min-height: 86px;
  resize: vertical;
  padding: 10px 12px;
}

.rating-actions {
  min-height: 66px;
  flex: 0 0 auto;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: #fafbf9;
  gap: 12px;
}

.validation-message {
  flex: 1 1 auto;
  color: var(--danger);
  font-size: 12px;
  text-align: center;
}

.review-screen,
.complete-screen {
  padding: 64px 0 90px;
}

.review-header {
  margin-bottom: 30px;
}

.review-header h1,
.complete-screen h1 {
  font-size: clamp(32px, 4vw, 46px);
}

.review-header > p:last-child,
.complete-screen > p:not(.eyebrow) {
  color: var(--muted);
}

.review-list {
  border-top: 1px solid var(--line);
}

.review-row {
  display: grid;
  min-height: 72px;
  align-items: center;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 14px;
}

.review-index {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.review-session-name {
  margin: 0;
  font-weight: 700;
}

.review-status {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.review-button {
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid #aeb9b2;
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}

.review-actions {
  justify-content: flex-end;
  margin-top: 28px;
  gap: 12px;
}

.complete-screen {
  max-width: 760px;
  text-align: center;
}

.completion-mark {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  margin: 0 auto 24px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 22px;
  font-weight: 800;
}

.complete-screen .eyebrow {
  margin-bottom: 10px;
}

.complete-screen > p:not(.eyebrow) {
  max-width: 580px;
  margin: 18px auto 28px;
}

.completion-actions {
  justify-content: center;
  gap: 12px;
}

.app-footer {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  text-align: center;
  font-size: 11px;
}

@media (max-width: 980px) {
  .start-screen {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .start-form {
    max-width: 560px;
  }

  .rating-workspace {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .transcript-panel {
    height: min(62vh, 680px);
  }

  .scale-panel {
    height: auto;
  }

  .scale-panel form {
    overflow: visible;
  }

  .rating-actions {
    position: sticky;
    z-index: 10;
    bottom: 0;
  }
}

@media (max-width: 620px) {
  .app-header {
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-subtitle,
  .rater-badge {
    display: none;
  }

  .start-screen {
    width: min(100% - 28px, 1120px);
    padding-top: 42px;
  }

  h1 {
    font-size: 36px;
  }

  .start-form {
    padding: 20px;
  }

  .rating-screen {
    padding: 12px 10px 22px;
  }

  .save-status {
    display: none;
  }

  .workflow-bar {
    min-height: 54px;
  }

  .workflow-bar > div {
    width: 100%;
    min-width: 0;
  }

  .progress-track {
    width: 100%;
  }

  .transcript-panel {
    height: 62vh;
  }

  .panel-header {
    min-height: 70px;
    padding: 13px 15px;
  }

  .transcript-body {
    padding: 18px 15px 40px;
  }

  .turn {
    max-width: 100%;
  }

  .anchor-legend {
    padding: 8px 10px;
    gap: 2px;
  }

  .anchor-legend span {
    display: grid;
    font-size: 9px;
    line-height: 1.15;
  }

  .scale-item {
    padding: 16px 14px 18px;
  }

  .scale-item legend {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .item-subscale {
    grid-column: 2;
    justify-self: start;
  }

  .rating-options {
    gap: 5px;
  }

  .rating-option span {
    min-height: 44px;
  }

  .rating-actions {
    padding: 9px 10px;
  }

  .rating-actions .primary-button,
  .rating-actions .secondary-button {
    padding-right: 12px;
    padding-left: 12px;
  }

  .validation-message {
    display: none;
  }

  .review-screen,
  .complete-screen {
    width: min(100% - 28px, 1120px);
    padding-top: 46px;
  }

  .review-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .review-button {
    grid-column: 2;
    justify-self: start;
  }

  .review-actions,
  .completion-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }
}
