/* ══════════════════════════════════════════════
   Rupture Repair — Design System & Styles
   Warm, calm, non-clinical palette (HSL)
   ══════════════════════════════════════════════ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --background: 40 30% 97%;
  --foreground: 30 15% 15%;
  --card: 40 25% 99%;
  --card-foreground: 30 15% 15%;
  --popover: 40 25% 99%;
  --popover-foreground: 30 15% 15%;
  --primary: 152 35% 42%;
  --primary-foreground: 150 30% 98%;
  --secondary: 350 30% 92%;
  --secondary-foreground: 350 25% 30%;
  --muted: 35 20% 93%;
  --muted-foreground: 30 10% 46%;
  --accent: 38 70% 55%;
  --accent-foreground: 38 60% 15%;
  --destructive: 0 55% 52%;
  --destructive-foreground: 0 0% 98%;
  --border: 35 20% 88%;
  --input: 35 20% 88%;
  --ring: 152 35% 42%;
  --radius: 0.625rem;

  --active-bg: 148 30% 94%;
  --active-border: 152 40% 58%;
  --active-glow: 152 50% 45%;
  --active-text: 152 35% 22%;
  --active-badge: 152 40% 40%;
  --listening-bg: 350 25% 95%;
  --listening-border: 350 25% 78%;
  --listening-text: 350 15% 40%;
  --listening-badge: 350 30% 55%;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* --- Screen visibility --- */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100vh; }

/* --- Layout --- */
.header {
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 1.25rem 1rem;
  text-align: center;
}
.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.header p { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.header .heart-icon { color: hsl(var(--primary)); }

.footer {
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 0.75rem 1rem;
  text-align: center;
}
.footer p { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

.main-content {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}
.main-content > .container { width: 100%; max-width: 42rem; }
.main-content > .container-lg { width: 100%; max-width: 64rem; }

/* --- Card --- */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.card + .card { margin-top: 1.5rem; }
.card-header { padding: 1.5rem 1.5rem 0.75rem; }
.card-header h3 { font-size: 1.125rem; font-weight: 600; color: hsl(var(--card-foreground)); }
.card-header p { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.card-body { padding: 0 1.5rem 1.5rem; }

/* --- Button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, opacity 150ms;
  line-height: 1.25rem;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-outline { background: transparent; border-color: hsl(var(--input)); color: hsl(var(--foreground)); }
.btn-outline:hover:not(:disabled) { background: hsl(var(--muted)); }
.btn-ghost { background: transparent; color: hsl(var(--muted-foreground)); }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover:not(:disabled) { opacity: 0.9; }
.btn-sm { font-size: 0.8125rem; padding: 0.375rem 0.75rem; }
.btn-lg { font-size: 1rem; padding: 0.625rem 1.5rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.5rem; width: 2.25rem; height: 2.25rem; }
.btn-selected { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }

/* --- Input --- */
.input, .textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: hsl(var(--background) / 0.6);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  outline: none;
  font-family: inherit;
  transition: border-color 150ms, background 150ms;
}
.input:focus, .textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
  background: hsl(var(--background));
}
.input.error { border-color: hsl(var(--destructive)); }
.textarea { resize: none; min-height: 80px; }
.error-text { font-size: 0.75rem; color: hsl(var(--destructive)); margin-top: 0.25rem; }

/* --- Label --- */
.label { font-size: 0.875rem; font-weight: 500; color: hsl(var(--foreground)); display: block; }
.label-sm { font-size: 0.75rem; color: hsl(var(--muted-foreground)); font-weight: 500; }

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
}
.badge-active {
  background: hsl(var(--active-badge));
  color: hsl(var(--primary-foreground));
  border-color: transparent;
}
.badge-listening {
  background: hsl(var(--listening-badge) / 0.2);
  color: hsl(var(--listening-text));
  border-color: hsl(var(--listening-border));
}

/* --- Radio cards --- */
.radio-card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  border: 2px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
}
.radio-card:hover { border-color: hsl(var(--muted-foreground) / 0.3); }
.radio-card.selected { border-color: hsl(var(--primary)); background: hsl(var(--active-bg)); }
.radio-card .radio-row { display: flex; align-items: center; gap: 0.5rem; }
.radio-card .radio-desc { font-size: 0.75rem; color: hsl(var(--muted-foreground)); padding-left: 1.5rem; }

/* --- Radio inline --- */
.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.25rem 0;
}
.radio-option input[type="radio"] {
  accent-color: hsl(var(--primary));
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}
.radio-option .radio-label { font-weight: 500; }
.radio-option .radio-sublabel { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

/* --- Range slider --- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: hsl(var(--muted));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: hsl(var(--primary));
  cursor: pointer;
  border: 2px solid hsl(var(--primary-foreground));
}

/* --- Progress bar --- */
.progress-bar {
  width: 100%;
  height: 4px;
  background: hsl(var(--muted));
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: hsl(var(--primary));
  border-radius: 2px;
  transition: width 300ms ease;
}

/* --- Emoji picker --- */
.emoji-picker-btn {
  font-size: 2rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid hsl(var(--border));
  background: transparent;
  cursor: pointer;
  transition: background 150ms;
}
.emoji-picker-btn:hover { background: hsl(var(--muted)); }
.emoji-grid {
  display: none;
  position: absolute;
  z-index: 50;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: 0 4px 16px hsl(0 0% 0% / 0.1);
  width: 18rem;
  max-height: 14rem;
  overflow-y: auto;
}
.emoji-grid.open { display: block; }
.emoji-grid-inner { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem; }
.emoji-cell {
  font-size: 1.25rem;
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: background 100ms;
}
.emoji-cell:hover { background: hsl(var(--muted)); }
.emoji-cell.selected { background: hsl(var(--primary) / 0.2); box-shadow: 0 0 0 1px hsl(var(--primary)); }

/* --- Feeling picker --- */
.feeling-picker { position: relative; }
.feeling-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: hsl(var(--background) / 0.6);
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}
.feeling-dropdown {
  display: none;
  position: absolute;
  z-index: 50;
  bottom: 100%;
  left: 0;
  width: 100%;
  margin-bottom: 0.25rem;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 4px 16px hsl(0 0% 0% / 0.1);
  max-height: 22rem;
  display: none;
  flex-direction: column;
}
.feeling-dropdown.open { display: flex; }
.feeling-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}
.feeling-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  font-family: inherit;
}
.feeling-search input::placeholder { color: hsl(var(--muted-foreground)); }
.feeling-list { overflow-y: auto; flex: 1; padding: 0.25rem 0; }
.feeling-group { padding: 0.375rem 0.75rem; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.feeling-chip {
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: filter 150ms;
}
.feeling-chip:hover { filter: brightness(0.9); }
.feeling-selected { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.5rem; }
.feeling-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.375rem 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.feeling-badge .remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.7;
  font-size: 0.875rem;
  line-height: 1;
  padding: 0.125rem;
  border-radius: 50%;
}
.feeling-badge .remove-btn:hover { opacity: 1; }
.feeling-empty { text-align: center; padding: 1rem; font-size: 0.875rem; color: hsl(var(--muted-foreground)); }

/* Feeling chip colors */
.chip-red-dark { background: #fecaca; color: #7f1d1d; }
.chip-red { background: #fee2e2; color: #991b1b; }
.chip-stone { background: #e7e5e4; color: #292524; }
.chip-amber { background: #fde68a; color: #78350f; }
.chip-orange { background: #fed7aa; color: #7c2d12; }
.chip-orange-light { background: #ffedd5; color: #9a3412; }
.chip-amber2 { background: #fde68a; color: #78350f; }
.chip-yellow { background: #fef08a; color: #713f12; }
.chip-yellow2 { background: #fef9c3; color: #713f12; }
.chip-lime { background: #d9f99d; color: #365314; }
.chip-green { background: #bbf7d0; color: #14532d; }
.chip-emerald { background: #a7f3d0; color: #064e3b; }
.chip-teal { background: #99f6e4; color: #134e4a; }
.chip-blue { background: #bfdbfe; color: #1e3a5f; }
.chip-indigo { background: #c7d2fe; color: #312e81; }
.chip-violet { background: #ddd6fe; color: #4c1d95; }
.chip-purple { background: #e9d5ff; color: #581c87; }

/* --- Panels (session screen) --- */
.panels-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  max-width: 64rem;
  margin: 0 auto;
  width: 100%;
}
@media (min-width: 768px) {
  .panels-row { flex-direction: row; gap: 0.5rem; padding: 1rem; }
}
.panel {
  flex: 1;
  border: 2px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: background 250ms, border-color 250ms, box-shadow 250ms;
}
@media (min-width: 768px) { .panel { padding: 1.5rem; } }
.panel.active-panel {
  background: hsl(var(--active-bg));
  border-color: hsl(var(--active-border));
  box-shadow: 0 0 20px hsl(var(--active-glow) / 0.15);
}
.panel.listening-panel {
  background: hsl(var(--listening-bg));
  border-color: hsl(var(--listening-border));
}
.panel-header { display: flex; align-items: center; justify-content: space-between; }
.panel-name { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.panel-name .emoji { font-size: 1.25rem; }
.panel-body { flex: 1; display: flex; flex-direction: column; }
.waiting-msg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* --- Step progress --- */
.step-progress {
  padding: 0.5rem 1rem;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
}
.step-progress-inner { max-width: 64rem; margin: 0 auto; }
.step-list { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; }
.step-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: opacity 100ms;
  color: hsl(var(--muted-foreground) / 0.5);
}
.step-item:hover { opacity: 0.8; }
.step-item.current { color: hsl(var(--primary)); }
.step-item.done { color: hsl(var(--muted-foreground)); }
.step-dot {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.step-item.current .step-dot { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.step-item.done .step-dot { background: hsl(var(--primary) / 0.2); color: hsl(var(--primary)); }

/* --- Session header --- */
.session-header {
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 0.75rem 1rem;
}
.session-header-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.session-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }

/* --- Speaker quote --- */
.speaker-quote {
  border-left: 4px solid hsl(var(--foreground));
  padding: 0.25rem 0 0.25rem 0.75rem;
}
.speaker-quote .meta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); display: flex; align-items: center; gap: 0.25rem; }
.speaker-quote .text { font-size: 0.875rem; margin-top: 0.25rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* --- Step header --- */
.step-header { margin-bottom: 1rem; }
.step-header h2 { font-size: 1.125rem; font-weight: 600; }
.step-header p { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-top: 0.5rem; line-height: 1.6; }
.step-header ul { margin-top: 0.5rem; list-style: none; }
.step-header li { font-size: 0.75rem; color: hsl(var(--muted-foreground)); display: flex; align-items: flex-start; gap: 0.375rem; }
.step-header li .bullet { color: hsl(var(--primary)); margin-top: 0.125rem; }

/* --- Cooldown --- */
.cooldown-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: hsl(var(--background));
}
.cooldown-card {
  width: 100%;
  max-width: 24rem;
  border: 2px solid hsl(var(--destructive) / 0.3);
  background: hsl(var(--card));
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 4px 24px hsl(0 0% 0% / 0.08);
}
.cooldown-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: hsl(var(--destructive) / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--destructive));
  font-size: 1.75rem;
}
.timer-ring { position: relative; width: 9rem; height: 9rem; display: flex; align-items: center; justify-content: center; }
.timer-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring .time { font-size: 1.875rem; font-family: monospace; font-weight: 700; font-variant-numeric: tabular-nums; z-index: 1; }
.timer-ring .time-label { font-size: 0.625rem; color: hsl(var(--muted-foreground)); z-index: 1; margin-top: 0.125rem; }

/* --- Summary --- */
.summary-partners { display: flex; align-items: center; justify-content: center; gap: 1rem; font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.entry-block { border-left: 2px solid hsl(var(--primary) / 0.2); padding-left: 1rem; margin-top: 1rem; }
.entry-block + .entry-block { margin-top: 1rem; }
.entry-speaker { font-size: 0.75rem; font-weight: 500; color: hsl(var(--muted-foreground)); }
.entry-text { font-size: 0.875rem; margin-top: 0.25rem; }
.entry-listener { margin-top: 0.5rem; padding-left: 0.75rem; border-left: 1px solid hsl(var(--listening-border)); }
.entry-listener p { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }

/* --- Anything more prompt --- */
.anything-more {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  text-align: center;
  padding: 1rem;
}
.anything-more p { font-size: 1rem; font-weight: 500; line-height: 1.6; }

/* --- Resume banner --- */
.resume-banner {
  border: 1px solid hsl(var(--primary) / 0.3);
  background: hsl(var(--active-bg));
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.resume-banner .resume-text { font-size: 0.875rem; color: hsl(var(--active-text)); display: flex; align-items: center; gap: 0.5rem; }

/* --- Grid helpers --- */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.space-y > * + * { margin-top: 0.5rem; }
.space-y-lg > * + * { margin-top: 1.5rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.relative { position: relative; }
.inline-flex { display: inline-flex; }
