:root {
  --background: #FAF7F4;
  --foreground: #2C2C2C;
  --card: #FFFFFF;
  --primary: #7EA991;
  --primary-foreground: #FFFFFF;
  --secondary: #D4846A;
  --secondary-foreground: #FFFFFF;
  --muted: #EEF4F1;
  --muted-foreground: #7A7A7A;
  --accent: #EEF4F1;
  --border: rgba(0, 0, 0, 0.08);
  --radius: 1rem;

  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Lora', Georgia, serif;

  --font-weight-normal: 400;
  --font-weight-medium: 500;

  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-4xl: 2.25rem;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { line-height: 1.6; }

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

.italic { font-style: italic; }
.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-muted { color: var(--muted-foreground); }

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

.col-sm { max-width: 28rem; }
.col-md { max-width: 42rem; }

.icon-circle {
  display: inline-block;
  padding: 1rem;
  border-radius: 9999px;
  background: rgba(126, 169, 145, 0.1);
  animation: iconCirclePop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.icon-circle.secondary {
  background: rgba(212, 132, 106, 0.1);
}

.icon-circle svg {
  display: block;
  width: 3rem;
  height: 3rem;
  color: var(--primary);
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-circle svg path,
.icon-circle svg line,
.icon-circle svg rect {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: iconDraw 5s ease-in-out 0.6s infinite;
}

.icon-circle svg path:nth-child(2),
.icon-circle svg line:nth-child(2),
.icon-circle svg rect:nth-child(2) { animation-delay: 0.9s; }

.icon-circle svg path:nth-child(3),
.icon-circle svg line:nth-child(3),
.icon-circle svg rect:nth-child(3) { animation-delay: 1.2s; }

.icon-circle svg path:nth-child(4),
.icon-circle svg line:nth-child(4) { animation-delay: 1.5s; }

.icon-circle svg path:nth-child(5),
.icon-circle svg line:nth-child(5) { animation-delay: 1.8s; }

@keyframes iconCirclePop {
  0%   { opacity: 0; transform: scale(0.6); }
  70%  { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes iconDraw {
  0%   { stroke-dashoffset: 200; }
  35%  { stroke-dashoffset: 0; }
  65%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -200; }
}

@media (prefers-reduced-motion: reduce) {
  .icon-circle,
  .icon-circle svg path,
  .icon-circle svg line,
  .icon-circle svg rect {
    animation: none;
    stroke-dashoffset: 0;
  }
}

.btn-primary,
.btn-secondary,
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  border-radius: 2rem;
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 4px 10px rgba(126, 169, 145, 0.25);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 0.75rem 1.5rem;
  border-radius: 1rem;
}

.btn-outline {
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  background: transparent;
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(212, 132, 106, 0.08);
  color: var(--secondary);
  border-color: rgba(212, 132, 106, 0.4);
}

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

.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  transform: scale(1.03);
  filter: brightness(0.92);
}

.btn-outline:hover:not(:disabled) {
  transform: scale(1.03);
  background: var(--muted);
  border-color: rgba(126, 169, 145, 0.4);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block { width: 100%; }

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

.card-lg { padding: 2rem; }

.card-accent {
  background: var(--accent);
  border: none;
  border-radius: 1.5rem;
  padding: 1.5rem;
}

.input,
.textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 1rem 1.5rem;
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.input:focus,
.textarea:focus {
  border-color: rgba(126, 169, 145, 0.5);
  box-shadow: 0 0 0 3px rgba(126, 169, 145, 0.2);
}

.textarea {
  min-height: 300px;
  resize: none;
  line-height: 1.6;
}

.textarea-compact {
  min-height: 3.25rem;
  overflow: hidden;
  border-radius: 1.25rem;
  font-size: var(--text-sm);
}

.dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 9999px;
  vertical-align: middle;
  flex-shrink: 0;
}
.dot-a { background: var(--primary); }
.dot-b { background: var(--secondary); }

.chat {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.msg {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: 1.5rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.msg-ai {
  background: var(--accent);
  font-style: italic;
  align-self: flex-start;
}

.msg-tension {
  border-left: 3px solid var(--secondary);
  background: rgba(212, 132, 106, 0.08);
}

.msg-crisis {
  border-left: 4px solid #B4454F;
  background: rgba(180, 69, 79, 0.08);
  color: var(--foreground);
  font-style: normal;
}

.crisis-banner {
  margin: 0 auto 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  background: rgba(180, 69, 79, 0.12);
  border: 1px solid rgba(180, 69, 79, 0.35);
  color: #8A2E36;
  font-size: var(--text-sm);
  text-align: center;
}

.crisis-card {
  max-width: 85%;
  padding: 1rem 1.1rem;
  border-radius: calc(var(--radius) * 1.25);
  background: #FFF5F3;
  border: 1px solid rgba(180, 69, 79, 0.4);
  box-shadow: 0 2px 8px rgba(180, 69, 79, 0.12);
  align-self: flex-start;
}

.crisis-card-heading {
  margin: 0 0 0.35rem;
  font-family: var(--font-serif, "Lora", serif);
  font-size: 1.05rem;
  font-weight: 500;
  color: #8A2E36;
}

.crisis-card-intro {
  margin: 0 0 0.65rem;
  font-size: var(--text-sm);
  color: var(--foreground);
  line-height: 1.4;
}

.crisis-card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.crisis-card-link {
  display: block;
  padding: 0.55rem 0.8rem;
  border-radius: 0.75rem;
  background: #FFFFFF;
  border: 1px solid rgba(180, 69, 79, 0.3);
  color: #8A2E36;
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
}

.crisis-card-link:hover {
  background: #FFEFED;
}

.msg-user {
  background: var(--card);
  border: 1px solid var(--border);
  align-self: flex-end;
}

.msg-partner-a {
  background: rgba(126, 169, 145, 0.1);
  border: 1px solid var(--primary);
  align-self: flex-start;
}

.msg-partner-b {
  background: rgba(212, 132, 106, 0.1);
  border: 1px solid var(--secondary);
  align-self: flex-end;
}

.chat-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
}

.chat-input-row .input { flex: 1; }

.chat-input-pill {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.chat-input-pill:focus-within {
  border-color: rgba(126, 169, 145, 0.5);
  box-shadow: 0 0 0 3px rgba(126, 169, 145, 0.2);
}

.chat-input-field {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  line-height: 1.5;
  padding: 0.55rem 0;
  max-height: 9rem;
  overflow-y: auto;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.chat-input-field:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.send-btn {
  flex-shrink: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1.5rem;
  background: var(--primary);
  color: var(--primary-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(126, 169, 145, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.send-btn:hover:not(:disabled) { transform: scale(1.05); filter: brightness(0.92); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.send-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send-btn-inline {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 1.25rem;
  box-shadow: none;
  align-self: flex-end;
}

.send-btn-inline svg { width: 1rem; height: 1rem; }

.mono {
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: var(--text-sm);
  word-break: break-all;
}

.icon-xs {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.share-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.share-row code {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  background: var(--muted);
  border-radius: 1rem;
}

.page-chat {
  justify-content: flex-start;
  padding: 2rem 1.5rem;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 42rem;
  min-height: calc(100vh - 4rem);
  gap: 1.5rem;
}

.chat-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chat-header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-header-row-split {
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
  flex-wrap: wrap;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.coach-progress {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.coach-progress li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.coach-progress li + li::before {
  content: "";
  display: block;
  width: 0.75rem;
  height: 1px;
  background: var(--border);
  margin-right: 0.1rem;
}

.coach-progress-num {
  flex: 0 0 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: var(--font-weight-medium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-foreground);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.coach-progress-label {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  letter-spacing: 0.01em;
  transition: color 0.2s ease;
}

.coach-progress li.is-active .coach-progress-num {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(126, 169, 145, 0.2);
}

.coach-progress li.is-active .coach-progress-label {
  color: var(--foreground);
  font-weight: var(--font-weight-medium);
}

.coach-progress li.is-done .coach-progress-num {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.coach-progress li.is-done .coach-progress-label {
  color: var(--muted-foreground);
}

@media (max-width: 32rem) {
  .coach-progress-label { display: none; }
  .coach-progress { gap: 0.25rem; }
  .coach-progress li + li::before { width: 0.5rem; }
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.msg-row {
  display: flex;
  width: 100%;
}

.msg-row-start { justify-content: flex-start; }
.msg-row-end { justify-content: flex-end; }

.quote-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quote-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.quote-item .dot {
  margin-top: 0.45rem;
}

.cta-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.cta-row .btn-primary,
.cta-row .btn-outline {
  padding: 1rem 1.5rem;
}

.awareness-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.awareness-title-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: center;
}

.awareness-title {
  font-size: var(--text-lg);
}

.awareness-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 32rem) {
  .awareness-options { grid-template-columns: 1fr; }
}

.awareness-option {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border-radius: 1.25rem;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.awareness-option:hover:not(:disabled) {
  border-color: rgba(126, 169, 145, 0.5);
}

.awareness-option-selected,
.awareness-option-selected:hover {
  border-color: var(--primary);
  background: rgba(126, 169, 145, 0.08);
}

.awareness-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.context-card,
.preview-card {
  background: var(--muted);
  border-radius: 1.25rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.preview-card {
  text-align: left;
}

.follow-option {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 1.5rem;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  text-align: center;
  font-weight: var(--font-weight-medium);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.follow-option:hover {
  border-color: rgba(126, 169, 145, 0.5);
}

.follow-option-selected,
.follow-option-selected:hover {
  border-color: var(--primary);
  background: rgba(126, 169, 145, 0.08);
}

.rating-row {
  display: flex;
  gap: 0.5rem;
}

.rating-option {
  flex: 1;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.rating-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.rating-label {
  font-size: var(--text-sm);
  color: var(--foreground);
}

.check-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto;
  border-radius: 9999px;
  background: rgba(126, 169, 145, 0.15);
}

.check-circle svg {
  width: 2rem;
  height: 2rem;
  color: var(--primary);
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spinner {
  width: 4rem;
  height: 4rem;
  border: 3px solid var(--muted);
  border-top-color: var(--primary);
  border-radius: 9999px;
  animation: spin 1s linear infinite;
}

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

.btn-loading-swap { display: contents; }
.btn-loading-swap .btn-ready { display: inline-flex; align-items: center; gap: 0.5rem; }
.btn-loading-swap .btn-busy  { display: none; align-items: center; gap: 0.5rem; }

button.is-loading .btn-loading-swap .btn-ready { display: none; }
button.is-loading .btn-loading-swap .btn-busy  { display: inline-flex; }

.btn-busy::after {
  content: "...";
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  width: 0;
  animation: dotCycle 1.4s steps(4, end) infinite;
}

@keyframes dotCycle {
  to { width: 1.1ch; }
}

.tulip-spinner {
  width: 1.1rem;
  height: 1.1rem;
  display: inline-block;
  color: currentColor;
}
.tulip-spinner svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
.tulip-spinner svg path {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: tulipBloom 1.8s ease-in-out infinite;
}
.tulip-spinner svg path:nth-child(2) { animation-delay: 0.15s; }
.tulip-spinner svg path:nth-child(3) { animation-delay: 0.3s; }

@keyframes tulipBloom {
  0%   { stroke-dashoffset: 40; }
  45%  { stroke-dashoffset: 0; }
  75%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -40; }
}

@media (prefers-reduced-motion: reduce) {
  .tulip-spinner svg path {
    animation: none;
    stroke-dashoffset: 0;
  }
  .btn-busy::after {
    animation: none;
    width: 1.1ch;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

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

.typing-line {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  font-style: italic;
  padding: 0 0.75rem 0.25rem;
  min-height: 1.25rem;
}

.typing-dots {
  display: inline-flex;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  background: var(--accent);
  border-radius: 1.5rem;
  align-self: flex-start;
}

.typing-dots span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--muted-foreground);
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

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

.flow-steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: var(--text-sm);
  color: var(--foreground);
  line-height: 1.5;
}

.flow-step-num {
  flex: 0 0 1.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.75rem;
  font-weight: var(--font-weight-medium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.text-left { text-align: left; }

.hint-card {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
}
.hint-card p { margin: 0; }

.lang-switch {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  display: inline-flex;
  padding: 0.2rem;
  gap: 0.15rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.lang-switch-btn {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted, #777);
  font-size: var(--text-sm, 0.85rem);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch-btn:hover:not(.lang-switch-btn-active) {
  color: var(--foreground);
}

.lang-switch-btn-active {
  background: rgba(126, 169, 145, 0.18);
  color: var(--foreground);
  font-weight: 500;
}
