:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --text: #24302f;
  --muted: #667674;
  --line: #dce5e1;
  --accent: #1f7a6b;
  --accent-dark: #14564c;
  --warn: #9a5c18;
  --danger: #b43b44;
  --shadow: 0 14px 36px rgba(24, 48, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.wechat-contact {
  position: relative;
  flex: 0 0 auto;
}

.wechat-btn {
  min-width: 86px;
  min-height: 40px;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.wechat-btn:hover {
  background: var(--accent-dark);
}

.wechat-toast {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 9px;
  width: 300px;
  max-width: min(300px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid #efd9bd;
  border-radius: 8px;
  background: linear-gradient(180deg, #fffaf2, #fff4e8);
  color: var(--text);
  box-shadow: 0 18px 42px rgba(89, 64, 35, 0.16);
  font-size: 13px;
  line-height: 1.5;
}

.wechat-toast-title {
  color: #6b3e14;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
}

.wechat-toast-credentials {
  display: grid;
  gap: 4px;
  color: #5d6c69;
  font-weight: 650;
}

.wechat-toast-id {
  padding: 9px 10px;
  border: 1px solid #ead0ad;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
}

.notice,
.panel,
.question-card,
.result-card,
.history-card,
.master-card,
.master-chat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.notice {
  margin-bottom: 14px;
  padding: 14px;
  border-color: #e6d4b9;
  background: #fffaf1;
  color: #4f3920;
}

.notice p,
.panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.fine-print {
  margin-top: 8px !important;
  font-size: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 16px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.intro-panel {
  background: linear-gradient(180deg, #ffffff, #f1f8f6);
}

.assessment-choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

.assessment-choice-card {
  display: grid;
  gap: 8px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
}

.assessment-choice-card:hover,
.assessment-choice-card:focus-visible {
  border-color: var(--accent);
  background: #f1faf7;
}

.assessment-choice-card span {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  background: #dff2ed;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.assessment-choice-card strong {
  font-size: 19px;
  line-height: 1.35;
}

.assessment-choice-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.question-list {
  display: grid;
  gap: 12px;
}

.dimension-heading {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #eef7f3;
}

.dimension-heading span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.dimension-heading h3 {
  margin: 0;
  font-size: 18px;
}

.dimension-heading p {
  margin: 0;
  color: var(--muted);
}

.question-card {
  padding: 16px;
}

.question-card legend {
  float: left;
  width: 100%;
  margin-bottom: 8px;
  padding: 0;
  color: var(--accent-dark);
  font-weight: 800;
}

.question-card legend + .question-text {
  clear: both;
}

.question-text {
  margin: 8px 0 14px;
}

.rating-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.rating-option input {
  position: absolute;
  opacity: 0;
}

.rating-option span {
  display: grid;
  min-height: 58px;
  place-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.rating-option strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}

.rating-option input:checked + span {
  border-color: var(--accent);
  background: #dff2ed;
  color: var(--accent-dark);
  font-weight: 700;
}

.hidden-trauma-option {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  cursor: pointer;
}

.hidden-trauma-option input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--accent);
}

.hidden-trauma-number {
  color: var(--accent-dark);
  font-weight: 900;
}

.hidden-trauma-copy {
  line-height: 1.65;
}

.checked-question-list {
  margin-top: 14px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 16px -16px -96px;
  padding: 12px 16px 20px;
  background: linear-gradient(180deg, rgba(246, 244, 239, 0), var(--bg) 26%);
}

.primary-btn,
.secondary-btn,
.danger-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.warn-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: #d88424;
  color: #fff;
  font-weight: 800;
}

.warn-btn:hover {
  background: #a85f13;
}

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

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

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

.danger-btn {
  background: #fdecee;
  color: var(--danger);
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.empty-state {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.status-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.result-stack,
.history-list,
.education-list {
  display: grid;
  gap: 12px;
}

.practice-stack {
  display: grid;
  gap: 12px;
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.practice-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.practice-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(27, 95, 80, 0.12);
  transform: translateY(-1px);
}

.practice-card span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.practice-card strong {
  font-size: 17px;
}

.practice-card small {
  color: var(--muted);
  line-height: 1.45;
}

.flashback-aid {
  display: grid;
  min-height: 520px;
  align-content: center;
  gap: 22px;
  padding: 32px 22px;
  border-radius: 8px;
  transition: background 0.45s ease;
}

.flashback-card {
  display: grid;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  padding: 34px 24px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  text-align: center;
}

.flashback-step {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.flashback-card h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.65;
  font-weight: 800;
}

.flashback-pause-line,
.flashback-card-line {
  display: block;
  text-align: center;
}

.flashback-pause-line {
  margin-bottom: 10px;
  font-size: 34px;
}

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

.flashback-reflect textarea {
  margin-top: 10px;
}

.flashback-response {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8e8;
  line-height: 1.75;
  white-space: pre-wrap;
}

.inner-child-shell {
  display: grid;
  gap: 12px;
}

.inner-child-intro {
  background: linear-gradient(180deg, #fffdf9, #f2faf4);
}

.inner-child-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inner-child-choice {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(69, 52, 31, 0.08);
}

.inner-child-choice.mothering {
  background: linear-gradient(135deg, #fff4f1, #fffaf0);
}

.inner-child-choice.fathering {
  background: linear-gradient(135deg, #eef8f2, #fffaf0);
}

.inner-child-choice span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.inner-child-choice strong {
  font-size: 22px;
}

.inner-child-choice small {
  color: var(--muted);
  line-height: 1.55;
}

.inner-child-aid {
  display: grid;
  min-height: 520px;
  align-content: center;
  gap: 22px;
  padding: 32px 22px;
  border-radius: 8px;
}

.inner-child-aid.mothering {
  background: linear-gradient(135deg, #fff1ee, #fffaf0);
}

.inner-child-aid.fathering {
  background: linear-gradient(135deg, #edf8f0, #fff7df);
}

.inner-child-card {
  display: grid;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  padding: 34px 24px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  text-align: center;
}

.inner-child-card h3 {
  margin: 0;
  font-size: 27px;
  line-height: 1.75;
  font-weight: 800;
}

.inner-child-reflect {
  background: linear-gradient(180deg, #fffdf9, #f8fbf6);
}

.grounding-shell {
  display: grid;
  gap: 14px;
}

.grounding-intro {
  display: grid;
  min-height: 500px;
  place-items: center;
  gap: 18px;
  padding: 32px 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e8f1f2, #f8fbf6);
  text-align: center;
}

.grounding-intro h3 {
  max-width: 520px;
  margin: 0;
  font-size: 27px;
  line-height: 1.65;
}

.grounding-breath-btn {
  width: min(320px, 100%);
  min-height: 94px;
  padding: 18px;
  border: 1px solid rgba(31, 122, 107, 0.3);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-dark);
  font-weight: 800;
  box-shadow: 0 16px 36px rgba(31, 122, 107, 0.14);
  cursor: pointer;
  animation: breathingPulse 3.2s ease-in-out infinite;
}

.grounding-aid {
  display: grid;
  min-height: 520px;
  align-content: center;
  gap: 22px;
  padding: 32px 22px;
  border-radius: 8px;
  background: linear-gradient(135deg, #edf4f5, #f7fbf1);
}

.grounding-card {
  display: grid;
  gap: 14px;
  max-width: 580px;
  margin: 0 auto;
  padding: 36px 26px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  text-align: center;
}

.grounding-card h3 {
  margin: 0;
  font-size: 25px;
  line-height: 1.8;
  font-weight: 800;
}

.grounding-reflect {
  background: linear-gradient(180deg, #f8fbfb, #f3faf4);
}

.grounding-reflect textarea {
  margin-top: 10px;
}

.inner-critic-shell {
  display: grid;
  gap: 14px;
}

.inner-critic-intro {
  display: grid;
  min-height: 500px;
  place-items: center;
  gap: 18px;
  padding: 32px 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f5faf4, #fffaf0);
  text-align: center;
}

.inner-critic-intro h3 {
  max-width: 540px;
  margin: 0;
  font-size: 26px;
  line-height: 1.65;
}

.inner-critic-start-btn {
  width: min(380px, 100%);
  min-height: 92px;
  padding: 18px;
  border: 1px solid rgba(31, 122, 107, 0.24);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-dark);
  font-weight: 800;
  line-height: 1.55;
  box-shadow: 0 16px 36px rgba(82, 104, 72, 0.12);
  cursor: pointer;
}

.inner-critic-aid {
  display: grid;
  min-height: 520px;
  align-content: center;
  gap: 22px;
  padding: 32px 22px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f6fbf3, #fff7e7);
}

.inner-critic-card {
  display: grid;
  gap: 14px;
  max-width: 580px;
  margin: 0 auto;
  padding: 36px 26px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  text-align: center;
}

.inner-critic-card h3 {
  margin: 0;
  font-size: 25px;
  line-height: 1.8;
  font-weight: 800;
}

.inner-critic-reflect {
  background: linear-gradient(180deg, #fffdf9, #f7fbf4);
}

.inner-critic-reflect textarea {
  margin-top: 10px;
}

.inner-critic-response {
  background: #fffaf0;
}

.relationship-shell {
  display: grid;
  gap: 12px;
}

.relationship-intro {
  background: linear-gradient(180deg, #fffdf8, #f1f7f4);
}

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

.relationship-choice {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(31, 67, 86, 0.08);
}

.relationship-choice.boundary {
  background: linear-gradient(135deg, #fff8e7, #f3faf4);
}

.relationship-choice.reality-check {
  background: linear-gradient(135deg, #edf4fb, #fff8ea);
}

.relationship-choice span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.relationship-choice strong {
  font-size: 22px;
}

.relationship-choice small {
  color: var(--muted);
  line-height: 1.55;
}

.relationship-aid {
  display: grid;
  min-height: 520px;
  align-content: center;
  gap: 22px;
  padding: 32px 22px;
  border-radius: 8px;
}

.relationship-aid.boundary {
  background: linear-gradient(135deg, #fff6df, #f4fbf5);
}

.relationship-aid.reality_check {
  background: linear-gradient(135deg, #eaf3fa, #fff5df);
}

.relationship-card {
  display: grid;
  gap: 14px;
  max-width: 600px;
  margin: 0 auto;
  padding: 36px 26px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  text-align: center;
}

.relationship-card h3 {
  margin: 0;
  font-size: 26px;
  line-height: 1.75;
  font-weight: 800;
}

.relationship-reflect {
  background: linear-gradient(180deg, #fffdf9, #f3faf6);
}

.relationship-reflect textarea {
  margin-top: 10px;
}

.fade-in-soft {
  animation: fadeInSoft 0.9s ease both;
}

@keyframes breathingPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.035);
  }
}

@keyframes fadeInSoft {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.explore-block {
  display: grid;
}

.manual-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.manual-page {
  min-height: 620px;
  padding: 34px 34px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.manual-line {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: #4c6f9f;
}

.manual-cover {
  display: grid;
  align-content: start;
  gap: 18px;
}

.manual-cover h2 {
  margin-top: 30px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.05;
  letter-spacing: 0;
}

.manual-cover h3 {
  color: #c7a344;
  font-size: 24px;
}

.manual-subtitle,
.manual-tip,
.manual-kicker,
.manual-en,
.manual-page footer span {
  color: var(--muted);
}

.manual-reading {
  margin-top: 96px;
}

.manual-reading h4 {
  margin: 0 0 12px;
  font-size: 18px;
}

.manual-reading p {
  margin: 8px 0;
  color: var(--muted);
}

.manual-page footer {
  display: grid;
  gap: 8px;
  margin-top: 100px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.manual-page footer strong {
  color: #4c6f9f;
}

.manual-contents h2 {
  margin-top: 52px;
  font-size: 40px;
}

.manual-en {
  margin: 6px 0 28px;
  color: #c7a344;
  font-family: Georgia, serif;
}

.manual-toc {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 26px;
  background: #f4f7f9;
}

.manual-toc-col {
  display: grid;
}

.manual-toc strong,
.manual-toc span {
  min-height: 38px;
  padding: 9px 12px;
  border-bottom: 1px solid #e8edf2;
}

.manual-toc strong {
  color: #436ca2;
}

.manual-tip {
  margin-top: 28px;
}

.manual-contact-panel {
  margin-top: 14px;
}

.master-grid {
  display: grid;
  gap: 12px;
}

.master-select-panel {
  display: block;
}

.master-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.master-card.active {
  border-color: var(--accent);
}

.master-card-head,
.master-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.master-chat-header {
  margin-bottom: 14px;
}

.master-chat-header .icon-btn {
  margin-left: auto;
}

.master-card-head p,
.master-chat-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.theme-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.theme-row span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.master-chat-panel {
  padding: 16px;
}

.icon-btn {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  font-size: 18px;
  box-shadow: none;
}

.result-card,
.history-card {
  padding: 16px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.score-tile {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.score-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.score-tile strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
}

.score-bars {
  display: grid;
  gap: 12px;
}

.score-bars.compact {
  gap: 10px;
}

.score-bar {
  display: grid;
  gap: 6px;
}

.score-bar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.score-bar-head span {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.score-bar-head strong {
  color: var(--accent-dark);
  font-size: 14px;
}

.score-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6efeb;
}

.score-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #d88424);
}

.score-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.result-explanation {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #fff8e8;
}

.result-explanation h3 {
  margin-bottom: 6px;
  color: var(--warn);
}

.result-explanation p {
  margin-bottom: 0;
  color: var(--text);
}

.guidance-list {
  padding-left: 18px;
  margin: 8px 0 0;
}

.chat-messages {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.chat-row.user {
  flex-direction: row-reverse;
}

.avatar {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.chat-row.user .avatar {
  background: #334b48;
}

.message {
  max-width: min(82%, 520px);
  padding: 12px;
  border-radius: 8px;
  white-space: pre-wrap;
}

.message.assistant {
  border: 1px solid var(--line);
  background: var(--surface);
}

.message.user {
  background: #dff2ed;
}

.message.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

button:disabled,
textarea:disabled {
  cursor: wait;
  opacity: 0.65;
}

.chat-input-row {
  display: grid;
  gap: 8px;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  color: var(--text);
}

.history-card time {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .rating-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .rating-option span {
    min-height: 54px;
    font-size: 10px;
  }

  .assessment-choice-grid {
    grid-template-columns: 1fr;
  }

  .assessment-choice-card {
    min-height: 0;
  }

  .score-grid {
    grid-template-columns: 1fr;
  }

  .practice-grid {
    grid-template-columns: 1fr;
  }

  .inner-child-choice-grid {
    grid-template-columns: 1fr;
  }

  .relationship-choice-grid {
    grid-template-columns: 1fr;
  }

  .flashback-aid {
    min-height: 460px;
    padding: 24px 14px;
  }

  .flashback-card h3 {
    font-size: 23px;
  }

  .inner-child-aid {
    min-height: 460px;
    padding: 24px 14px;
  }

  .inner-child-card h3 {
    font-size: 22px;
  }

  .grounding-intro,
  .grounding-aid {
    min-height: 460px;
    padding: 24px 14px;
  }

  .grounding-intro h3,
  .grounding-card h3 {
    font-size: 22px;
  }

  .inner-critic-intro,
  .inner-critic-aid {
    min-height: 460px;
    padding: 24px 14px;
  }

  .inner-critic-intro h3,
  .inner-critic-card h3 {
    font-size: 22px;
  }

  .relationship-aid {
    min-height: 460px;
    padding: 24px 14px;
  }

  .relationship-card h3 {
    font-size: 22px;
  }

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

  .tab {
    font-size: 12px;
  }

  .manual-preview {
    grid-template-columns: 1fr;
  }

  .manual-page {
    min-height: auto;
    padding: 24px 18px;
  }

  .manual-reading,
  .manual-page footer {
    margin-top: 36px;
  }

  .manual-toc {
    grid-template-columns: 1fr;
  }
}
