:root {
  color-scheme: light;
  --bg: #edf3f5;
  --bg-warm: #fff8ef;
  --panel: #ffffff;
  --panel-soft: #f7faf9;
  --panel-strong: #eef7f5;
  --ink: #18242a;
  --muted: #61717a;
  --line: #dbe4e7;
  --line-strong: #c8d6dc;
  --sidebar: #13211f;
  --sidebar-soft: #223631;
  --sidebar-line: rgba(255, 255, 255, 0.12);
  --accent: #087f7b;
  --accent-strong: #045f5c;
  --accent-soft: #e6f4f2;
  --warm: #df7142;
  --warm-strong: #b94f2a;
  --warm-soft: #fff0e7;
  --sun: #ffd166;
  --danger: #b84a4a;
  --shadow: 0 18px 44px rgba(21, 34, 42, 0.08);
  --shadow-soft: 0 10px 24px rgba(21, 34, 42, 0.07);
  --shadow-hover: 0 14px 30px rgba(21, 34, 42, 0.10);
  --radius: 8px;
  --ease: 160ms ease;
  --app-header-height: 72px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f9fbfb 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Fredoka", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(8, 127, 123, 0.18);
}

img {
  max-width: 100%;
}

*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(8, 127, 123, 0.26);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(8, 127, 123, 0.42);
  border: 3px solid transparent;
  background-clip: padding-box;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition:
    background-color var(--ease),
    border-color var(--ease),
    box-shadow var(--ease),
    color var(--ease),
    transform var(--ease);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(8, 127, 123, 0.26);
  outline-offset: 2px;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

body.patient-mode {
  height: 100svh;
  overflow: hidden;
}

body.patient-mode .app-shell {
  height: 100svh;
  min-height: 0;
  overflow: hidden;
}

.app-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid rgba(202, 216, 222, 0.78);
  backdrop-filter: blur(14px);
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy h1 {
  margin: 0;
}

.brand-copy p {
  font-size: 0.9rem;
}

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

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 209, 102, 0.10), transparent 28%),
    linear-gradient(160deg, #111c1b 0%, var(--sidebar) 48%, #243137 100%);
  color: #eef7f6;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-right: 1px solid rgba(8, 18, 21, 0.22);
  box-shadow: 10px 0 34px rgba(18, 33, 31, 0.13);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, #ffe29a, var(--sun) 54%, #f4a261);
  color: #172120;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(255, 209, 102, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.brand h1,
.panel-head h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand h1 {
  color: var(--ink);
}

.app-header .brand-mark {
  width: 42px;
  height: 42px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: none;
}

.panel-head p,
.target-meta {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.settings {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field span,
.field legend,
.field summary {
  color: #dbe9e6;
  font-size: 0.9rem;
  font-weight: 700;
}

.field summary {
  cursor: pointer;
  list-style-position: inside;
}

.field summary::marker {
  color: var(--sun);
  font-size: 0.82rem;
}

.collapsible-field {
  gap: 0;
}

.collapsible-field[open] summary {
  margin-bottom: 8px;
}

.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: var(--sidebar-soft);
  color: #ffffff;
  padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

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

.segmented button {
  min-height: 42px;
  border-radius: var(--radius);
  background: var(--sidebar-soft);
  color: #e8f2f0;
  border: 1px solid var(--sidebar-line);
  font-weight: 700;
}

.segmented button:hover {
  background: #2b403b;
}

.segmented button[aria-pressed="true"] {
  background: linear-gradient(145deg, var(--sun), #f8b35f);
  border-color: var(--sun);
  color: #18211f;
  box-shadow: 0 10px 24px rgba(255, 209, 102, 0.18);
}

.check-list {
  width: 100%;
  max-height: 236px;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: var(--sidebar-soft);
  scrollbar-color: rgba(255, 255, 255, 0.32) transparent;
}

.check-list.compact {
  max-height: 178px;
}

.check-group {
  display: grid;
  gap: 6px;
}

.check-group + .check-group {
  padding-top: 8px;
  border-top: 1px solid #39504c;
}

.check-group-title {
  color: #9eb2ae;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.check-option {
  min-height: 34px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius);
  color: #ffffff;
  cursor: pointer;
  transition: background-color var(--ease);
}

.check-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.check-option input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--sun);
}

.check-option span {
  min-width: 0;
  color: #e8f2f0;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.3;
}

.workspace {
  width: 100%;
  max-width: 1180px;
  min-height: calc(100svh - var(--app-header-height));
  min-width: 0;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 40px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(18px, 2vw, 28px);
  align-items: start;
}

body:not(.patient-mode) .workspace {
  padding-bottom: clamp(68px, 8vw, 92px);
}

.sound-tile {
  width: min(90%, clamp(190px, 44vmin, 460px));
  max-height: 100%;
  aspect-ratio: 1.35;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #ffffff, #f1faf8);
  border: 1px solid rgba(8, 127, 123, 0.28);
  color: var(--accent-strong);
  font-size: clamp(4rem, 13vw, 9rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 24px 60px rgba(8, 127, 123, 0.16), inset 0 0 0 2px rgba(8, 127, 123, 0.09);
}

.prompt-label {
  margin: 0;
  color: var(--warm-strong);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.84rem;
}

.target-text {
  margin-top: 8px;
  font-size: clamp(2.8rem, 7vw, 5.7rem);
  line-height: 1.04;
  font-weight: 850;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  color: #142329;
}

.target-text.phrase {
  font-size: clamp(2rem, 4.8vw, 4.25rem);
}

.target-meta {
  min-height: 1.4em;
  color: var(--muted);
  font-weight: 650;
}

.card-actions {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.card-actions button,
.empty-action {
  min-height: 48px;
  border-radius: var(--radius);
  color: #ffffff;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(8, 127, 123, 0.18);
}

.card-actions button:nth-child(2),
.empty-action {
  background: linear-gradient(145deg, var(--warm), var(--warm-strong));
  box-shadow: 0 10px 22px rgba(223, 113, 66, 0.18);
}

.card-actions button:not(:disabled):hover,
.empty-action:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.practice-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.practice-actions button {
  min-height: 48px;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 850;
}

.practice-actions button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.52);
}

.error {
  color: var(--danger);
}

.is-hidden {
  display: none !important;
}

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

.builder-view,
.homework-view,
.patient-view {
  grid-column: 1 / -1;
  min-width: 0;
}

.builder-view {
  width: min(100%, 900px);
  display: block;
  margin: 0 auto;
}

.wizard-card,
.builder-preview,
.homework-card,
.patient-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(202, 216, 222, 0.74);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.wizard-card,
.homework-card {
  --card-pad: clamp(22px, 3vw, 34px);
  --card-pad-neg: clamp(-34px, -3vw, -22px);
  padding: var(--card-pad);
}

.wizard-card {
  padding: var(--card-pad);
  border-color: rgba(202, 216, 222, 0.58);
  box-shadow: 0 12px 34px rgba(21, 34, 42, 0.06);
}

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

.field-hint {
  margin: 0;
  font-size: 0.9rem;
}

.builder-preview {
  padding: 18px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 60px);
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 253, 252, 0.86)),
    var(--panel);
  scrollbar-color: rgba(8, 127, 123, 0.35) transparent;
}

.wizard-topline,
.patient-progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.wizard-topline {
  min-height: 40px;
}

.wizard-topline h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0;
}

.wizard-topline .warning-list {
  min-height: 36px;
  justify-items: end;
  margin-bottom: 0;
}

.homework-card h2 {
  margin: 0;
  font-size: clamp(1.7rem, 2.5vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: 0;
}

.wizard-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.wizard-status span {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 850;
  white-space: nowrap;
}

.preview-toggle {
  min-height: 36px;
  padding: 0 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid var(--accent-strong);
  box-shadow: 0 2px 8px rgba(8, 127, 123, 0.12);
}

.preview-toggle:hover:not(:disabled) {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent-strong);
  box-shadow: 0 4px 12px rgba(8, 127, 123, 0.2);
}

.eyebrow {
  width: fit-content;
  margin: 0 0 7px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--warm-soft);
  color: var(--warm-strong);
  border: 1px solid rgba(223, 113, 66, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.progress-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
}

.progress-steps span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.progress-steps span:not(:last-child)::after {
  content: "\2192";
  color: rgba(97, 113, 122, 0.54);
  font-size: 0.74rem;
}

.progress-track {
  height: 3px;
  margin: 0 0 18px;
  border-radius: 999px;
  background: #edf2f4;
  overflow: hidden;
  box-shadow: none;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(8, 127, 123, 0.72);
  transition: width 160ms ease;
}

.builder-step-content {
  min-height: 420px;
}

.guided-step {
  display: grid;
  gap: 18px;
  align-content: start;
}

.step-intro {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 650;
}

.target-context {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--warm-soft);
  border: 1px solid rgba(223, 113, 66, 0.16);
  color: var(--ink);
  font-weight: 750;
}

.target-context strong {
  color: var(--warm);
}

.option-grid,
.phoneme-button-grid,
.category-button-grid,
.checkbox-grid,
.review-grid {
  display: grid;
  gap: 10px;
}

.option-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.option-card,
.phoneme-button,
.category-button {
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid rgba(202, 216, 222, 0.66);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  padding: 14px;
  box-shadow: none;
  transition:
    border-color var(--ease),
    box-shadow var(--ease),
    transform var(--ease),
    background-color var(--ease);
}

.option-card:hover,
.phoneme-button:hover,
.category-button:hover {
  border-color: rgba(8, 127, 123, 0.24);
  box-shadow: 0 6px 18px rgba(8, 127, 123, 0.06);
  transform: translateY(-1px);
}

.option-card {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.option-card strong,
.phoneme-button strong,
.category-button strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  word-break: break-word;
}

.option-card span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  word-break: break-word;
  font-weight: 550;
}

.option-card.is-selected,
.phoneme-button.is-selected,
.category-button.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(8, 127, 123, 0.10);
  background: var(--accent-soft);
}

.option-card.is-unavailable {
  background: #f5f8f8;
  color: #6f7f86;
}

.option-card.is-unavailable span {
  color: #718188;
}

.selected-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.selected-label {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 850;
}

.selected-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.target-step .selected-chips {
  flex-wrap: wrap;
}

.selected-chip,
.empty-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 850;
  line-height: 1.2;
}

.selected-chip {
  border: 1px solid rgba(8, 127, 123, 0.16);
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: none;
}

.selected-chip span:last-child {
  font-size: 0.9rem;
  color: var(--warm);
}

.empty-chip {
  color: var(--muted);
  background: transparent;
  padding-left: 0;
}

.target-selection-summary {
  position: static;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  margin: -2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.target-summary-selected,
.target-summary-count {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  line-height: 1.2;
}

.target-summary-selected {
  flex: 1 1 220px;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.target-summary-selected strong {
  color: var(--accent-strong);
  font-size: 0.96rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.target-summary-count {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.target-sound-picker {
  display: grid;
  gap: 14px;
}

.sound-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.sound-section + .sound-section {
  padding-top: 14px;
  border-top: 1px solid rgba(219, 228, 231, 0.64);
}

.sound-section h3,
.sound-group-title {
  margin: 0;
  letter-spacing: 0;
}

.sound-section h3 {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.sound-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
}

.sound-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sound-tab-button {
  min-height: 34px;
  border: 1px solid rgba(219, 228, 231, 0.72);
  border-radius: 999px;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.sound-tab-button:hover {
  border-color: rgba(8, 127, 123, 0.28);
  color: var(--ink);
  background: #fbfdfd;
}

.sound-tab-button.is-selected {
  border-color: rgba(8, 127, 123, 0.34);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sound-tab-panel {
  display: grid;
  gap: 9px;
}

.sound-group-title {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.sound-chip-grid {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 7px;
}

.target-sound-picker .phoneme-button.sound-chip {
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 44px;
  border-radius: 999px;
  padding: 6px 11px !important;
  background: rgba(255, 255, 255, 0.58);
  border-color: rgba(202, 216, 222, 0.62);
  box-shadow: none;
}

.target-sound-picker .phoneme-button.sound-chip:hover {
  border-color: rgba(8, 127, 123, 0.28);
  background: #fbfdfd;
  box-shadow: 0 5px 12px rgba(8, 127, 123, 0.05);
  transform: translateY(-1px);
}

.target-sound-picker .phoneme-button.sound-chip strong {
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.1;
}

.target-sound-picker .phoneme-button.sound-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(8, 127, 123, 0.08);
}

.sound-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.split-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.split-picker h3,
.step-section h3 {
  margin: 0 0 10px;
  letter-spacing: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.phoneme-picker {
  max-height: none;
  overflow: visible;
  display: grid;
  gap: 10px;
  padding: 0;
}

.phoneme-tier {
  border: 1px solid rgba(219, 228, 231, 0.64);
  border-radius: var(--radius);
  background: rgba(247, 250, 249, 0.54);
  overflow: visible;
  box-shadow: none;
}

.phoneme-tier summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0;
  transition: background-color var(--ease), color var(--ease);
}

.phoneme-tier summary:hover {
  background: var(--panel-soft);
}

.phoneme-tier[open] summary {
  border-bottom: 1px solid rgba(219, 228, 231, 0.82);
}

.phoneme-tier .phoneme-button-grid,
.category-tier .category-button-grid {
  padding: 8px 8px 12px;
}

.phoneme-button-grid,
.category-button-grid {
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.phoneme-button,
.category-button {
  min-height: 60px;
  text-align: center;
  padding: 8px !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.phoneme-button strong,
.category-button strong {
  font-size: 1.08rem;
}

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

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

.refine-step {
  gap: 22px;
}

.advanced-panel {
  border-top: 1px solid rgba(219, 228, 231, 0.64);
  padding-top: 6px;
}

.advanced-panel summary {
  min-height: 46px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  font-weight: 700;
}

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

.advanced-panel summary::after {
  content: "+";
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(8, 127, 123, 0.18);
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
}

.advanced-panel[open] summary::after {
  content: "-";
}

.advanced-panel summary span,
.advanced-panel summary small {
  display: block;
}

.advanced-panel summary small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 550;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-top: 12px;
}

.step-section,
.builder-field,
.homework-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.target-step {
  gap: 10px;
}

.target-step .phoneme-picker {
  margin-top: 2px;
}

.avoid-tier-content .phoneme-picker {
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.step-section.wide,
.builder-field.wide,
.builder-field.light,
.homework-field {
  grid-column: 1 / -1;
}

.builder-field span,
.homework-field legend {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
}

.builder-field small {
  color: var(--muted);
  line-height: 1.35;
  font-weight: 650;
}

.builder-field select,
.builder-field input,
.builder-field textarea,
.link-box textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  font: inherit;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.92), inset 0 1px 2px rgba(21, 34, 42, 0.035);
  transition:
    border-color var(--ease),
    box-shadow var(--ease),
    background-color var(--ease);
}

.builder-field select:hover,
.builder-field input:hover,
.builder-field textarea:hover,
.link-box textarea:hover {
  border-color: var(--line-strong);
}

.builder-field select:focus,
.builder-field input:focus,
.builder-field textarea:focus,
.link-box textarea:focus {
  border-color: rgba(8, 127, 123, 0.46);
  box-shadow: 0 0 0 4px rgba(8, 127, 123, 0.08);
}

.builder-field textarea,
.link-box textarea {
  min-height: 110px;
  resize: vertical;
}

.success-target-control {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.success-stepper {
  display: grid;
  grid-template-columns: 54px minmax(128px, 1fr) 54px;
  align-items: stretch;
  flex: 1 1 360px;
  max-width: 540px;
  min-height: 56px;
  border: 1px solid rgba(8, 127, 123, 0.18);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(8, 127, 123, 0.08);
  overflow: hidden;
}

.success-stepper-button {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 0;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.success-stepper-button:hover {
  background: var(--accent);
  color: #ffffff;
}

.success-target-value {
  display: grid;
  place-items: center;
  gap: 0;
  min-width: 0;
  padding: 7px 10px;
  border-inline: 1px solid rgba(8, 127, 123, 0.14);
  background: linear-gradient(180deg, #ffffff, #f8fcfb);
}

.success-target-value input {
  width: 100%;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 900;
  box-shadow: none;
  padding: 0;
}

.success-target-value input:hover,
.success-target-value input:focus {
  border: 0;
  box-shadow: none;
}

.success-target-value small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

.success-target-presets {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 1 auto;
  min-width: 0;
}

.success-target-presets span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
}

.success-target-presets button {
  min-height: 40px;
  min-width: 48px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.success-target-presets button:hover {
  border-color: rgba(8, 127, 123, 0.30);
  color: var(--ink);
  background: #fbfdfd;
}

.success-target-presets button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(8, 127, 123, 0.14);
}

.inline-toggle,
.wizard-actions,
.patient-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-toggle button,
.primary-button,
.secondary-button,
.tertiary-button,
.patient-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.inline-toggle button {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(8, 127, 123, 0.12);
}

.inline-toggle button[aria-pressed="true"] {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(8, 127, 123, 0.16);
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(8, 127, 123, 0.14);
}

.warm-button {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(8, 127, 123, 0.16);
  box-shadow: none;
}

.secondary-button {
  background: #f4f8f8;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.tertiary-button {
  background: #f4f8f8;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tertiary-button:hover {
  color: var(--ink);
  border-color: var(--line);
  background: #f2f7f7;
}

.primary-button:not(:disabled):hover,
.warm-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.inline-toggle button:not(:disabled):hover,
.patient-actions button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.action-spacer {
  flex: 1 1 auto;
}

.wizard-actions {
  position: static;
  z-index: 5;
  margin: 26px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid rgba(219, 228, 231, 0.64);
  background: transparent;
  backdrop-filter: none;
}

#homeworkView .wizard-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#homeworkView .wizard-actions .primary-button,
#homeworkView .wizard-actions .secondary-button {
  width: 100%;
  min-width: 0;
  padding-inline: 10px;
}

.wizard-actions:has(#builderHomework:not(.is-hidden)) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wizard-actions:has(#builderHomework:not(.is-hidden)) .action-spacer {
  display: none;
}

.wizard-actions:has(#builderHomework:not(.is-hidden)) button {
  width: 100%;
  min-width: 0;
  padding-inline: 10px;
}

.checkbox-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.checkbox-grid label,
.toggle-row,
.radio-row {
  min-height: 42px;
  display: flex;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: linear-gradient(180deg, #ffffff, #fbfdfd);
  font-weight: 750;
  box-shadow: 0 4px 12px rgba(21, 34, 42, 0.035);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.checkbox-grid label:hover,
.toggle-row:hover,
.radio-row:hover {
  border-color: rgba(8, 127, 123, 0.26);
  box-shadow: var(--shadow-soft);
}

.toggle-row {
  justify-content: flex-start;
}

.toggle-row.light,
.radio-row {
  border-color: #e2e8ec;
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10.5rem;
  gap: 14px;
  align-items: center;
}

.age-slider,
.syllable-slider,
.difficulty-slider,
.length-slider {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), var(--line));
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.age-slider::-webkit-slider-thumb,
.syllable-slider::-webkit-slider-thumb,
.difficulty-slider::-webkit-slider-thumb,
.length-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  cursor: pointer;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 12px rgba(8, 127, 123, 0.28);
  transition: all 160ms ease;
}

.age-slider::-webkit-slider-thumb:hover,
.syllable-slider::-webkit-slider-thumb:hover,
.difficulty-slider::-webkit-slider-thumb:hover,
.length-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 16px rgba(8, 127, 123, 0.38);
}

.age-slider::-moz-range-thumb,
.syllable-slider::-moz-range-thumb,
.difficulty-slider::-moz-range-thumb,
.length-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  cursor: pointer;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 12px rgba(8, 127, 123, 0.28);
  transition: all 160ms ease;
}

.age-slider::-moz-range-thumb:hover,
.syllable-slider::-moz-range-thumb:hover,
.difficulty-slider::-moz-range-thumb:hover,
.length-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 16px rgba(8, 127, 123, 0.38);
}

.age-slider::-moz-range-track,
.syllable-slider::-moz-range-track,
.difficulty-slider::-moz-range-track,
.length-slider::-moz-range-track {
  background: transparent;
  border: 0;
}

.slider-value {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-weight: 800;
  color: var(--ink);
}

.slider-value strong {
  font-size: 0.95rem;
}

.toggle-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}

.choice-pills {
  grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
}

.toggle-group button {
  min-height: 46px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border: 1px solid rgba(219, 228, 231, 0.74);
  font-weight: 650;
  font-size: 0.9rem;
  box-shadow: none;
  transition:
    background-color var(--ease),
    border-color var(--ease),
    box-shadow var(--ease),
    color var(--ease),
    transform var(--ease);
}

.toggle-group button:hover {
  border-color: rgba(8, 127, 123, 0.30);
  box-shadow: none;
  transform: translateY(-1px);
}

.toggle-group button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(8, 127, 123, 0.08);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.section-heading h3,
.section-heading p {
  margin: 0;
}

.section-heading p {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}

.section-heading > span,
.section-heading > strong {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-weight: 900;
}

.avoid-tier-content {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.warning-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.warning-list:empty {
  display: none;
}

.warning-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fff9ef;
  color: #72501b;
  border: 1px solid #f2dcae;
  line-height: 1.4;
  box-shadow: none;
}

.wizard-topline .warning-item {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  line-height: 1.2;
  text-align: right;
}

.warning-item.error {
  background: #fff0f0;
  color: var(--danger);
  border-color: #efc6c6;
}

.warning-item p {
  margin: 6px 0 0;
  color: inherit;
  font-size: 0.9rem;
}

.preview-list {
  display: grid;
  gap: 8px;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  justify-items: end;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 28, 32, 0.32);
}

.preview-dialog {
  position: relative;
  width: min(520px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 22px;
  background: #ffffff;
  box-shadow: -14px 0 42px rgba(21, 34, 42, 0.18);
  overflow: hidden;
}

.preview-dialog .panel-head {
  padding-right: 84px;
}

.preview-summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.preview-summary-row p {
  margin: 0;
}

.preview-close-button {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 1;
}

.preview-dialog .preview-list {
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  padding-right: 4px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.preview-row {
  min-height: 64px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(219, 228, 231, 0.86);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: none;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.preview-row:hover {
  border-color: rgba(8, 127, 123, 0.24);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.preview-row img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.preview-row strong,
.preview-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-row small {
  margin-top: 2px;
  color: var(--muted);
}

.preview-exclude {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid rgba(173, 52, 52, 0.16);
  background: #fff7f6;
  color: var(--danger);
  font-weight: 900;
  line-height: 1;
}

.preview-exclude:hover {
  background: #fdebea;
  border-color: rgba(173, 52, 52, 0.3);
}

.mini-sound {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
  border: 1px solid rgba(8, 127, 123, 0.12);
}

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

.review-stack {
  display: grid;
  gap: 18px;
}

.review-summary {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}

.review-summary-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(112px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid rgba(219, 228, 231, 0.78);
}

.review-summary dt,
.review-summary dd {
  min-width: 0;
  margin: 0;
  line-height: 1.4;
}

.review-summary dt {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.review-summary dd {
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.sorting-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sound-tile.word-only {
  font-size: clamp(2rem, 8vw, 4.5rem);
  padding: 18px;
}

.homework-grid {
  display: grid;
  grid-template-columns: minmax(0, 340px);
  gap: 18px;
  justify-content: center;
  margin-top: 18px;
}

.homework-options {
  display: grid;
  gap: 16px;
  align-content: start;
}

.homework-field {
  margin: 0;
  padding: 0;
  border: 0;
  align-content: start;
}

.homework-output {
  display: grid;
  gap: 8px;
  align-content: start;
}

.homework-output #homeworkLinkWarning:empty {
  display: none;
}

.link-box {
  display: grid;
  gap: 7px;
}

.link-box label {
  font-weight: 850;
}

.qr-card {
  display: grid;
  place-items: center;
}

.qr-svg {
  width: min(100%, 220px);
  height: auto;
}

.two-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.patient-mode .app-shell {
  grid-template-columns: 1fr;
}

body.patient-mode .sidebar {
  display: none;
}

body.patient-mode .workspace {
  height: 100%;
  min-height: 0;
  grid-template-columns: 1fr;
  padding: 24px;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(8, 127, 123, 0.11), transparent 42%),
    linear-gradient(315deg, rgba(255, 209, 102, 0.18), transparent 40%);
}

.patient-view {
  width: min(900px, 100%);
  height: 100%;
  max-height: 760px;
  min-height: 0;
  display: grid;
}

.patient-card {
  position: relative;
  height: 100%;
  min-height: 0;
  padding: clamp(20px, 3vw, 30px);
  padding-bottom: calc(clamp(20px, 3vw, 30px) + 58px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88)),
    var(--panel);
  overflow: hidden;
}

.patient-progress {
  color: var(--muted);
  display: grid;
  gap: 10px;
  font-weight: 850;
}

.patient-progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e6eef1;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(24, 36, 42, 0.08);
}

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

.patient-stage {
  --stage-media-pad: clamp(14px, 4vmin, 32px);
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid rgba(202, 216, 222, 0.84);
  background:
    linear-gradient(135deg, rgba(8, 127, 123, 0.12), transparent 55%),
    linear-gradient(315deg, rgba(255, 209, 102, 0.22), transparent 52%),
    linear-gradient(180deg, #ffffff, #f4f9f8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -18px 40px rgba(8, 127, 123, 0.035);
  overflow: hidden;
}

.patient-stage:has(.patient-reel)::before,
.patient-stage:has(.patient-reel)::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: clamp(38px, 10%, 92px);
  pointer-events: none;
}

.patient-stage:has(.patient-reel)::before {
  left: 0;
  background: linear-gradient(90deg, rgba(244, 249, 248, 0.98), rgba(244, 249, 248, 0));
}

.patient-stage:has(.patient-reel)::after {
  right: 0;
  background: linear-gradient(270deg, rgba(244, 249, 248, 0.98), rgba(244, 249, 248, 0));
}

.patient-reel {
  --reel-item-width: min(72%, 420px);
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 30px);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-padding-inline: max(var(--stage-media-pad), calc((100% - var(--reel-item-width)) / 2));
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-overflow-scrolling: touch;
  padding: var(--stage-media-pad) max(var(--stage-media-pad), calc((100% - var(--reel-item-width)) / 2));
}

.patient-reel.is-grabbed,
.patient-reel.is-dragging,
.patient-reel.is-dragging .patient-reel-item {
  cursor: grabbing;
}

.patient-reel.is-dragging,
.patient-reel.is-direct-scrolling,
.patient-reel.is-snapping {
  scroll-snap-type: none;
}

.patient-reel.is-dragging,
.patient-reel.is-snapping {
  scrollbar-width: none;
}

.patient-reel.is-dragging::-webkit-scrollbar,
.patient-reel.is-snapping::-webkit-scrollbar {
  display: none;
}

.patient-reel-item {
  flex: 0 0 var(--reel-item-width);
  height: 100%;
  max-height: 480px;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2.2vmin, 20px);
  border-radius: var(--radius);
  border: 1px solid rgba(202, 216, 222, 0.82);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 8px 20px rgba(21, 34, 42, 0.055);
  opacity: 0.54;
  scroll-snap-align: center;
  transform: scale(0.86);
  -webkit-user-drag: none;
  transition:
    transform 190ms ease,
    opacity 190ms ease,
    border-color var(--ease),
    background-color var(--ease),
    box-shadow var(--ease);
}

.patient-reel-item.is-active {
  border-color: rgba(8, 127, 123, 0.30);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(8, 127, 123, 0.13);
  opacity: 1;
  transform: scale(1);
}

.patient-reel-item:not(.is-active):hover {
  opacity: 0.76;
}

.patient-reel-item:not(:disabled):active {
  transform: scale(0.98);
}

.patient-reel-item:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -5px;
}

.patient-reel-item img,
.patient-reel-item .sound-tile {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.patient-reel-item img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.patient-reel-item .sound-tile {
  width: 100%;
  max-width: 100%;
}

.patient-stage img {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 480px;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}

.patient-stage .patient-reel-item img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.patient-stage-button {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  min-height: 0;
  padding: var(--stage-media-pad);
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}

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

.patient-stage-button img {
  pointer-events: none;
}

.patient-prompt {
  min-height: 0;
  text-align: center;
}

.patient-actions {
  position: absolute;
  left: clamp(20px, 3vw, 30px);
  right: clamp(20px, 3vw, 30px);
  bottom: clamp(20px, 3vw, 30px);
  align-self: end;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.patient-actions.is-complete {
  grid-template-columns: minmax(0, 1fr);
}

.patient-actions button {
  min-width: 0;
  width: 100%;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(8, 127, 123, 0.18);
}

.patient-actions button[hidden] {
  display: none;
}

.patient-actions .secondary-button {
  background: #f4f8f8;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(21, 34, 42, 0.05);
}

.completion-card {
  text-align: center;
}

.completion-card h2 {
  margin: 0 0 8px;
  font-size: clamp(2.4rem, 8vw, 5rem);
  letter-spacing: 0;
}

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

.print-sheet {
  position: relative;
  z-index: 1;
  display: none;
}

@media print {
  body {
    background: #ffffff;
  }

  body::before {
    display: none;
  }

  .app-shell {
    display: none !important;
  }

  .print-sheet {
    display: block;
  }

  .print-page {
    width: 190mm;
    min-height: 277mm;
    margin: 0 auto;
    color: #111;
    font-family: "Fredoka", "Segoe UI", Arial, sans-serif;
    font-weight: 600;
  }

  .print-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38mm;
    gap: 12mm;
    align-items: start;
    border-bottom: 1px solid #d8d8d8;
    padding-bottom: 7mm;
  }

  .print-header h1 {
    margin: 0 0 3mm;
    font-size: 22pt;
    letter-spacing: 0;
  }

  .print-header p,
  .print-page footer {
    margin: 0;
    line-height: 1.45;
    font-size: 10.5pt;
  }

  .print-qr {
    display: grid;
    justify-items: center;
    gap: 2mm;
    font-size: 8pt;
    font-weight: 700;
  }

  .print-qr-fallback {
    width: 32mm;
    min-height: 32mm;
    display: grid;
    place-items: center;
    border: 1px solid #d6d6d6;
    text-align: center;
    padding: 2mm;
  }

  .print-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5mm;
  }

  .print-card {
    min-height: 42mm;
    display: grid;
    place-items: center;
    gap: 2mm;
    border: 1px solid #d6d6d6;
    border-radius: 3mm;
    padding: 3mm;
    break-inside: avoid;
    text-align: center;
  }

  .print-card img {
    width: 24mm;
    height: 24mm;
    object-fit: contain;
  }

  .print-card strong {
    font-size: 14pt;
    letter-spacing: 0;
  }

  .print-page footer {
    margin-top: 7mm;
    color: #555;
  }
}

@page {
  size: A4;
  margin: 10mm;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .builder-view,
  .homework-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: auto;
    padding: 20px;
  }

  .workspace {
    padding: 18px;
  }

  .builder-preview {
    max-height: none;
  }

  .wizard-topline {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
  }

  .wizard-status {
    width: 100%;
    justify-content: space-between;
  }

  .target-selection-summary {
    top: 8px;
  }
}

@media (max-width: 560px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .app-header-actions {
    width: 100%;
  }

  .app-header .brand {
    width: 100%;
    gap: 10px;
  }

  .app-header .brand-mark {
    width: 36px;
    height: 36px;
  }

  .app-header .brand h1 {
    font-size: 1.2rem;
  }

  .app-header .preview-toggle {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .wizard-topline {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
  }

  .wizard-topline .warning-list {
    justify-items: start;
    width: 100%;
  }

  .wizard-topline .warning-item {
    text-align: left;
  }

  .card-actions,
  .segmented,
  .exercise-grid,
  .option-grid,
  .split-picker,
  .setup-grid,
  .filter-grid,
  .advanced-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .patient-stage img {
    max-height: 360px;
  }

  .patient-reel {
    --reel-item-width: min(82%, 330px);
    gap: 12px;
  }

  .patient-reel-item {
    max-height: 360px;
    padding: 12px;
  }

  .sound-tile {
    width: min(90%, clamp(170px, 54vmin, 360px));
  }

  .target-text {
    font-size: clamp(2.4rem, 14vw, 4.2rem);
  }

  .target-text.phrase {
    font-size: clamp(1.7rem, 10vw, 3rem);
  }

  .wizard-card,
  .homework-card,
  .patient-card {
    padding: 18px;
  }

  .wizard-card,
  .homework-card {
    --card-pad: 18px;
    --card-pad-neg: -18px;
  }

  .patient-card {
    padding-bottom: 76px;
  }

  .patient-actions {
    left: 18px;
    right: 18px;
    bottom: 18px;
  }

  .target-selection-summary {
    position: static;
  }

  .success-target-control {
    align-items: stretch;
    flex-direction: column;
  }

  .success-stepper {
    flex-basis: auto;
    max-width: none;
  }

  .success-target-presets {
    flex-wrap: wrap;
  }

  .sound-section {
    padding: 0;
  }

  .sound-section + .sound-section {
    padding-top: 12px;
  }

  .sound-section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .sound-tabs {
    width: 100%;
  }

  .sound-tab-button {
    flex: 1 1 auto;
  }

  .wizard-actions,
  .patient-actions {
    align-items: center;
  }

  body:not(.patient-mode) .workspace {
    padding-bottom: 18px;
  }

  .progress-steps {
    gap: 6px;
    font-size: 0.72rem;
  }

  .progress-steps span {
    gap: 6px;
  }

  .review-summary {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .review-summary-row {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 10px 0;
  }

  .wizard-actions:has(#builderHomework:not(.is-hidden)) {
    grid-template-columns: 1fr;
  }

  .wizard-actions {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 22px var(--card-pad-neg) var(--card-pad-neg);
    padding: 12px var(--card-pad);
    border-top: 1px solid rgba(219, 228, 231, 0.88);
    border-radius: 0 0 var(--radius-large) var(--radius-large);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 24px rgba(21, 34, 42, 0.06);
  }

  .wizard-actions .action-spacer {
    display: none;
  }

  .wizard-actions button,
  .wizard-actions .primary-button,
  .wizard-actions .secondary-button,
  .wizard-actions .tertiary-button {
    width: 100%;
    min-width: 0;
  }

  .wizard-actions:has(#builderHomework:not(.is-hidden)) button {
    width: 100%;
  }

  .slider-row {
    grid-template-columns: 1fr;
  }

  .slider-value {
    min-width: auto;
  }

  .toggle-group button {
    min-width: 48px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-dialog {
    width: 100%;
  }
}

body.patient-mode {
  background: #f7fbf9;
  transition: background-color 220ms ease;
}

body.patient-mode .app-shell {
  grid-template-rows: minmax(0, 1fr);
  height: 100svh;
  min-height: 0;
}

body.patient-mode .app-header {
  display: none;
}

body.patient-mode .workspace {
  width: 100%;
  max-width: none;
  height: 100svh;
  min-height: 0;
  padding: clamp(12px, 3vw, 28px);
  place-items: stretch;
  background: linear-gradient(180deg, #fafffd 0%, #eef7f2 100%);
}

body.patient-mode:has(.patient-view.is-success) {
  background: #11a761;
}

body.patient-mode:has(.patient-view.is-success) .workspace {
  background: #11a761;
}

.patient-view {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  display: grid;
  border-radius: 18px;
  overflow: hidden;
  transition: background-color 180ms ease;
}

.patient-view.is-success {
  background: #11a761;
  animation: patientSuccessWash 1000ms ease both;
}

.patient-card {
  position: relative;
  height: 100%;
  min-height: 0;
  padding: clamp(16px, 3.2vw, 34px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 2vh, 20px);
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  overflow: hidden;
}

.patient-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #11a761;
  opacity: 0;
  pointer-events: none;
}

.patient-view.is-success .patient-card::after {
  animation: patientSuccessOverlay 425ms ease both;
}

.patient-progress {
  width: min(100%, 760px);
  justify-self: center;
  gap: 8px;
  color: #315149;
}

.patient-progress-labels {
  min-height: 22px;
  justify-content: flex-end;
  font-size: clamp(0.88rem, 2.4vw, 1rem);
}

#patientSoundSummary {
  display: none;
}

.patient-progress-track {
  height: clamp(12px, 2vh, 18px);
  border: 1px solid rgba(49, 81, 73, 0.12);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 3px rgba(24, 36, 42, 0.08);
}

.patient-progress-track span {
  background: linear-gradient(90deg, #12a364, #6ccf55);
  transition: width 240ms ease;
}

.patient-view.is-success .patient-progress,
.patient-view.is-success .target-text {
  color: #ffffff;
}

.patient-view.is-success .patient-progress-track {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.38);
}

.patient-stage {
  --stage-media-pad: clamp(6px, 2vmin, 18px);
  min-height: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.patient-single-card {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

.patient-single-card img,
.patient-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 22px 42px rgba(24, 36, 42, 0.12));
}

.patient-single-card .sound-tile {
  width: min(100%, 560px);
  max-height: 100%;
  border: 0;
  background: #ffffff;
  box-shadow: 0 20px 52px rgba(8, 127, 123, 0.13);
}

.patient-prompt {
  position: static;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 0;
  padding-bottom: calc(58px + clamp(14px, 2.4vw, 24px));
  text-align: center;
}

.patient-prompt .prompt-label,
.patient-prompt .target-meta {
  display: none;
}

.target-text {
  max-width: min(100%, 980px);
  margin: 0;
  color: #172c27;
  font-size: clamp(3.2rem, 12vw, 8rem);
  line-height: 0.96;
  font-weight: 900;
  letter-spacing: 0;
  text-wrap: balance;
}

.target-text.phrase {
  font-size: clamp(2.2rem, 8vw, 5.5rem);
}

@media (max-width: 560px) {

}

.patient-actions {
  position: absolute;
  z-index: 5;
  left: 50%;
  right: auto;
  bottom: clamp(16px, 3vw, 32px);
  width: min(100% - 32px, 460px);
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 10px;
  transform: translateX(-50%);
}

.patient-view.is-complete .patient-actions {
  display: grid;
}

.patient-actions button {
  min-height: 52px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  color: #274942;
  border: 1px solid rgba(49, 81, 73, 0.16);
  box-shadow: 0 12px 28px rgba(24, 36, 42, 0.10);
  font-weight: 900;
}

.patient-actions .patient-nav-button {
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.45rem;
  line-height: 1;
}

.patient-actions button:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.96);
  transform: translateY(-1px);
}

.patient-actions button:disabled {
  opacity: 0;
}

.patient-actions.is-complete {
  width: min(100% - 32px, 420px);
  grid-template-columns: minmax(0, 1fr);
}

.patient-actions.is-complete button {
  background: #087f7b;
  color: #ffffff;
}

.patient-actions.is-complete button:not(:disabled):hover {
  background: #0a716f;
  color: #ffffff;
}

.patient-success-mark {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: clamp(8rem, 28vw, 18rem);
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform: scale(0.55);
  pointer-events: none;
  text-shadow: 0 16px 36px rgba(0, 91, 48, 0.22);
}

.patient-view.is-success .patient-success-mark {
  animation: patientTickPop 700ms cubic-bezier(0.2, 1.28, 0.34, 1) both;
}

.patient-view.is-success .patient-single-card,
.patient-view.is-success .target-text {
  animation: patientPromptSuccess 760ms ease both;
}

.completion-card {
  display: grid;
  place-items: center;
  gap: 10px;
  color: #172c27;
  text-align: center;
}

.completion-card h2 {
  margin: 0;
  font-size: clamp(3.2rem, 12vw, 8rem);
}

.completion-card p {
  margin: 0;
  color: #52655f;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: 750;
}

.patient-view.is-complete .patient-stage {
  overflow-y: auto;
}

.completion-card.session-summary {
  width: min(100%, 720px);
  align-content: start;
  gap: 14px;
  padding: clamp(8px, 2vw, 20px);
}

.completion-card.session-summary h2 {
  font-size: clamp(2.4rem, 8vw, 5rem);
}

.session-summary-lead {
  max-width: 38rem;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(8, 127, 123, 0.09);
}

.session-summary-metrics {
  width: 100%;
  margin: 0;
  display: grid;
  gap: 2px;
  overflow: hidden;
  border: 1px solid rgba(49, 81, 73, 0.14);
  border-radius: 16px;
  background: rgba(49, 81, 73, 0.10);
  text-align: left;
}

.session-summary-metrics div {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.92);
}

.session-summary-metrics dt {
  color: #52655f;
  font-weight: 750;
}

.session-summary-metrics dd {
  margin: 0;
  color: #172c27;
  font-weight: 900;
}

.session-summary-note {
  max-width: 38rem;
  color: #657872;
}

@keyframes patientSuccessWash {
  0% {
    background: #f7fbf9;
  }

  22%,
  100% {
    background: #11a761;
  }
}

@keyframes patientSuccessOverlay {
  0% {
    opacity: 0;
  }

  18% {
    opacity: 0.88;
  }

  100% {
    opacity: 0;
  }
}

@keyframes patientTickPop {
  0% {
    opacity: 0;
    transform: scale(0.42) rotate(-8deg);
  }

  42% {
    opacity: 1;
    transform: scale(1.08) rotate(0deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes patientPromptSuccess {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0.16;
    transform: scale(0.96);
  }
}

@media (max-width: 560px) {
  .session-summary-metrics div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  body.patient-mode .workspace {
    padding: 10px;
  }

  .patient-view,
  .patient-card {
    border-radius: 14px;
  }

  .patient-card {
    padding: 14px;
  }

  .patient-progress-labels {
    font-size: 0.86rem;
  }

  .patient-single-card img,
  .patient-stage img {
    max-width: 90vw;
    max-height: min(48svh, 380px);
  }

  .target-text {
    font-size: clamp(3rem, 17vw, 5.8rem);
  }

  .target-text.phrase {
    font-size: clamp(2rem, 11vw, 3.8rem);
  }

}

body.patient-mode .workspace {
  background: #f7fbf9;
}

.patient-card {
  grid-template-rows: auto minmax(180px, 1fr) auto;
  gap: clamp(8px, 1.6vh, 14px);
  padding-bottom: calc(clamp(16px, 3.2vw, 34px) + 76px);
}

.patient-progress {
  width: min(100%, 680px);
  gap: 6px;
}

.patient-progress-labels {
  min-height: 18px;
  justify-content: flex-end;
  color: #315149;
  font-size: 0.9rem;
  font-weight: 900;
}

.patient-progress-track {
  height: 6px;
  border: 0;
  background: rgba(49, 81, 73, 0.14);
}

.patient-stage {
  align-content: center;
  gap: 0;
}

.patient-single-card {
  width: min(100%, 560px);
  height: min(100%, 46svh, 430px);
  max-height: 430px;
  position: relative;
  top: clamp(-18px, -2.2vh, -10px);
  align-self: end;
  padding: clamp(4px, 1.5vmin, 12px);
}

.patient-single-card img,
.patient-stage img {
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(0 18px 30px rgba(24, 36, 42, 0.10));
}

.patient-single-card .sound-tile {
  width: min(100%, 460px);
  min-height: min(34svh, 280px);
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: clamp(4rem, 18vw, 9rem);
}

.patient-card-tray {
  width: min(54vw, 360px);
  height: clamp(14px, 2.6vh, 24px);
  margin-top: clamp(-10px, -1.2vh, -4px);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(49, 81, 73, 0.18), rgba(49, 81, 73, 0.06) 58%, transparent 72%);
}

.patient-prompt {
  gap: 8px;
  padding-bottom: 0;
}

.target-text {
  max-width: min(100%, 820px);
  position: relative;
  top: clamp(-14px, -1.8vh, -8px);
  font-size: clamp(2.5rem, 8vw, 5.8rem);
  line-height: 0.98;
}

.target-text.phrase {
  font-size: clamp(1.85rem, 5.8vw, 4.2rem);
}

.patient-actions {
  width: min(100% - 32px, 460px);
  grid-template-columns: 52px minmax(0, 1fr) 52px;
}

.patient-actions button {
  min-height: 52px;
  border-radius: 999px;
  background: #087f7b;
  color: #ffffff;
}

.patient-actions button:not(:disabled):hover {
  background: #0a716f;
  color: #ffffff;
}

.patient-actions button:disabled {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 560px) {
  .patient-card {
    gap: 8px;
    padding: 12px;
    padding-bottom: 82px;
  }

  .patient-actions {
    left: 50%;
    right: auto;
    bottom: 8px;
    width: min(calc(100% - 24px), 460px);
    transform: translateX(-50%);
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 8px;
  }

  .patient-actions #patientPrevious {
    grid-column: 1;
  }

  .patient-actions #patientNext {
    grid-column: 2;
  }

  .patient-actions #patientForward {
    grid-column: 3;
  }

  .patient-actions .patient-nav-button {
    width: 48px;
    height: 56px;
    min-height: 56px;
  }

  .patient-actions button {
    min-height: 56px;
  }

  .patient-single-card {
    height: min(100%, 38svh, 330px);
    top: -8px;
  }

  .target-text {
    top: -8px;
    font-size: clamp(2.35rem, 13vw, 4.7rem);
  }

  .target-text.phrase {
    font-size: clamp(1.7rem, 8vw, 3.1rem);
  }

}

@media (prefers-reduced-motion: reduce) {
  .patient-view.is-success,
  .patient-view.is-success .patient-card::after,
  .patient-view.is-success .patient-success-mark,
  .patient-view.is-success .patient-single-card,
  .patient-view.is-success .target-text {
    animation-duration: 1ms;
  }

  .patient-progress-track span {
    transition-duration: 1ms;
  }
}
