/* =====================================================
   Recovery Companion · رفيق التعافي
   style.css — Production stylesheet
   ===================================================== */

/* ── Design Tokens ──────────────────────────────────── */
:root {
  --global-bar-height: 52px;

  /* Palette */
  --color-bg:           #F4F6F4;
  --color-surface:      #FFFFFF;
  --color-surface-alt:  #F0F3F0;
  --color-border:       #E2E8E2;
  --color-border-soft:  #EDF0ED;

  --color-sage:         #6B8F71;
  --color-sage-dark:    #4E6E54;
  --color-sage-light:   #E8EFE9;
  --color-teal:         #4A9B8E;
  --color-teal-light:   #E4F3F1;
  --color-teal-dark:    #357A6F;

  --color-text:         #2D3B2E;
  --color-text-muted:   #6B7D6C;
  --color-text-subtle:  #9AA89B;
  --color-text-inverse: #FFFFFF;

  --color-warning:      #C17B2D;
  --color-warning-bg:   #FDF5E8;

  /* Typography */
  --font-display:  'Lora', Georgia, serif;
  --font-body:     'Inter', system-ui, -apple-system, sans-serif;

  --text-xs:    0.75rem;
  --text-sm:    0.875rem;
  --text-base:  1rem;
  --text-lg:    1.125rem;
  --text-xl:    1.25rem;
  --text-2xl:   1.5rem;
  --text-3xl:   1.875rem;
  --text-4xl:   2.25rem;

  --weight-light:    300;
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;

  /* Spacing */
  --space-1:   0.25rem;
  --space-2:   0.5rem;
  --space-3:   0.75rem;
  --space-4:   1rem;
  --space-5:   1.25rem;
  --space-6:   1.5rem;
  --space-8:   2rem;
  --space-10:  2.5rem;
  --space-12:  3rem;
  --space-16:  4rem;
  --space-20:  5rem;
  --space-24:  6rem;

  /* Radii */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(45,59,46,0.04), 0 4px 16px rgba(45,59,46,0.06);
  --shadow-card-hover: 0 4px 8px rgba(45,59,46,0.06), 0 12px 32px rgba(45,59,46,0.1);
  --shadow-input: 0 0 0 3px rgba(74,155,142,0.15);
  --shadow-btn:   0 1px 2px rgba(45,59,46,0.1), 0 4px 12px rgba(107,143,113,0.2);

  /* Transitions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:   150ms;
  --duration-base:   250ms;
  --duration-slow:   400ms;
  --duration-screen: 350ms;

  /* Layout */
  --max-width-content: 640px;
  --max-width-chat:    720px;
  --header-height:     64px;
}

/* ── Reset & Base ───────────────────────────────────── */
[hidden] { display: none !important; }

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* RTL support */
[dir="rtl"] { text-align: right; }
[dir="ltr"] { text-align: left; }

img, svg { display: block; }

ul, ol { list-style: none; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

textarea {
  font-family: inherit;
  font-size: inherit;
  resize: none;
  border: none;
  outline: none;
  background: none;
}

/* Focus visible — accessibility */
:focus-visible {
  outline: 2px solid var(--color-teal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Screen System ──────────────────────────────────── */
#app {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  min-height: calc(100dvh - var(--global-bar-height));
  transition: padding-left 300ms var(--ease-smooth);
}

body.sidebar-open #app {
  padding-left: min(320px, 88vw);  /* sidebar always on the left */
}

.screen {
  position: absolute;
  inset: 0;
  min-height: calc(100dvh - var(--global-bar-height));
  background-color: var(--color-bg);
  overflow-y: auto;
  overflow-x: hidden;

  /* Hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity var(--duration-screen) var(--ease-smooth),
    transform var(--duration-screen) var(--ease-smooth);
  will-change: opacity, transform;
}

.screen--active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
  position: relative;
}

/* Slide in from right for sub-screens */
.screen--entering {
  animation: slideInRight var(--duration-screen) var(--ease-smooth) forwards;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── HOME SCREEN ────────────────────────────────────── */
#screen-home {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  padding-top: var(--space-16);
}

/* ── Home top bar (hamburger) ─────────────────────────── */
.home-topbar {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  height: var(--global-bar-height);
  padding: var(--space-2) var(--space-4);
  z-index: 210;
  display: flex;
  align-items: center;
}

.home-topbar__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--color-text-subtle);
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.home-topbar__menu-btn:hover,
.home-topbar__menu-btn:focus-visible {
  background: var(--color-surface-hover, rgba(0,0,0,0.06));
  color: var(--color-text);
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.home-topbar__menu-btn svg {
  width: 20px;
  height: 20px;
}

.home__inner {
  width: 100%;
  max-width: var(--max-width-content);
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

/* Logo mark */
.home__header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
}

.logo-mark {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-sage);
}

.logo-mark__ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--color-sage);
  opacity: 0.3;
  animation: breathe 4s ease-in-out infinite;
}

.logo-mark__ring--outer {
  width: 80px;
  height: 80px;
  animation-delay: 0s;
}

.logo-mark__ring--inner {
  width: 60px;
  height: 60px;
  opacity: 0.2;
  animation-delay: 0.8s;
}

@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: 0.25; }
  50%       { transform: scale(1.08); opacity: 0.45; }
}

.logo-mark__icon {
  width: 40px;
  height: 40px;
  color: var(--color-sage);
  position: relative;
  z-index: 1;
}

/* Brand name */
.home__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.brand__name {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand__name--arabic {
  font-size: var(--text-xl);
  font-weight: var(--weight-regular);
  color: var(--color-text-muted);
  font-family: var(--font-display);
  letter-spacing: 0;
}

.home__subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.7;
  max-width: 400px;
  text-align: center;
  font-weight: var(--weight-light);
}

/* Navigation cards */
.home__nav { width: 100%; }

.nav-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.nav-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-5) var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  text-align: left;
  transition:
    transform var(--duration-base) var(--ease-smooth),
    box-shadow var(--duration-base) var(--ease-smooth),
    border-color var(--duration-base) var(--ease-smooth),
    background-color var(--duration-base) var(--ease-smooth);
  cursor: pointer;
  position: relative;
}

[dir="rtl"] .nav-card { text-align: right; }

.nav-card:hover:not(.nav-card--locked) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--color-border);
}

.nav-card:active:not(.nav-card--locked) {
  transform: translateY(0);
  box-shadow: var(--shadow-card);
}

/* Primary card — Start Journey */
.nav-card--primary {
  background: linear-gradient(135deg, #FFFFFF 0%, #F2F7F3 100%);
  border-color: var(--color-sage-light);
}

.nav-card--primary .nav-card__icon { color: var(--color-sage); }
.nav-card--primary .nav-card__title { color: var(--color-sage-dark); }

/* Chat card */
.nav-card--chat .nav-card__icon { color: var(--color-teal); }
.nav-card--chat .nav-card__title { color: var(--color-teal-dark); }
.nav-card--chat:hover {
  border-color: var(--color-teal-light);
}

/* Locked card */
.nav-card--locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.nav-card--locked:hover { transform: none; box-shadow: var(--shadow-card); }

.nav-card__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background-color var(--duration-base) var(--ease-smooth);
}

.nav-card__icon svg {
  width: 22px;
  height: 22px;
}

.nav-card:hover:not(.nav-card--locked) .nav-card__icon {
  background: var(--color-sage-light);
}

.nav-card--chat:hover .nav-card__icon { background: var(--color-teal-light); }

.nav-card__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nav-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  line-height: 1.3;
}

.nav-card__subtitle {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  line-height: 1.3;
}

.nav-card__desc {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  line-height: 1.4;
  margin-top: var(--space-1);
}

.journey-home-badge {
  display: inline-block;
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: 500;
  margin-top: var(--space-1);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.nav-card__arrow {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--color-text-subtle);
  line-height: 1;
  transition: transform var(--duration-base) var(--ease-smooth);
}

[dir="rtl"] .nav-card__arrow { transform: scaleX(-1); }

.nav-card:hover:not(.nav-card--locked) .nav-card__arrow {
  transform: translateX(3px);
}

[dir="rtl"] .nav-card:hover:not(.nav-card--locked) .nav-card__arrow {
  transform: scaleX(-1) translateX(3px);
}

.nav-card__lock {
  flex-shrink: 0;
  color: var(--color-text-subtle);
}
.nav-card__lock svg { width: 18px; height: 18px; }

/* Footer */
.home__footer {
  text-align: center;
  padding-bottom: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.home__footer-text {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.home__footer-text::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-sage);
  opacity: 0.5;
}

.home__footer-sub {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  opacity: 0.7;
  line-height: 1.5;
}

/* ── SHARED HEADERS ─────────────────────────────────── */
.subscreen-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: rgba(244, 246, 244, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  min-height: var(--header-height);
}

.subscreen-header__titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.subscreen-header__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  line-height: 1.2;
}

.subscreen-header__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.2;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  transition:
    background-color var(--duration-fast) var(--ease-smooth),
    color var(--duration-fast) var(--ease-smooth);
}

.back-btn:hover {
  background: var(--color-sage-light);
  color: var(--color-sage-dark);
}

.back-btn svg { width: 18px; height: 18px; pointer-events: none; }

[dir="rtl"] .back-btn svg { transform: scaleX(-1); }

/* ── CONVERSATION SCREENS (chat + assessment journey) ── */
#screen-chat,
#screen-assessment {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--global-bar-height));
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: rgba(244, 246, 244, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  min-height: var(--header-height);
}

.chat-header__brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-header__name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  line-height: 1.2;
}

.chat-header__name--arabic {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.2;
}

.chat-header__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-sage);
  animation: pulse-status 2.5s ease-in-out infinite;
}

@keyframes pulse-status {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(107, 143, 113, 0.4); }
  50%       { opacity: 0.8; box-shadow: 0 0 0 5px rgba(107, 143, 113, 0); }
}

.status-label {
  font-size: var(--text-xs);
  color: var(--color-sage);
  font-weight: var(--weight-medium);
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: var(--max-width-chat);
  width: 100%;
  margin: 0 auto;
  scroll-behavior: smooth;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* Message bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: messageAppear var(--duration-slow) var(--ease-bounce);
  will-change: opacity, transform;
}

@keyframes messageAppear {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.message--companion {
  align-self: flex-start;
  align-items: flex-start;
}

.message--user {
  align-self: flex-end;
  align-items: flex-end;
}

[dir="rtl"] .message--companion { align-self: flex-end; align-items: flex-end; }
[dir="rtl"] .message--user      { align-self: flex-start; align-items: flex-start; }

.message__bubble {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-xl);
  line-height: 1.65;
  font-size: var(--text-base);
  position: relative;
  word-break: break-word;
  white-space: pre-line;
}

.message--companion .message__bubble {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

[dir="rtl"] .message--companion .message__bubble { border-bottom-left-radius: var(--radius-xl); border-bottom-right-radius: var(--radius-sm); }

.message--user .message__bubble {
  background: var(--color-sage);
  color: var(--color-text-inverse);
  border-bottom-right-radius: var(--radius-sm);
}

[dir="rtl"] .message--user .message__bubble { border-bottom-right-radius: var(--radius-xl); border-bottom-left-radius: var(--radius-sm); }

.message__time {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  margin-top: var(--space-1);
  padding: 0 var(--space-2);
}

/* Journey cards (exercise, current_challenge) rendered inside conversation */
.journey-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-5);
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: var(--shadow-card);
  animation: messageAppear var(--duration-slow) var(--ease-bounce);
}

.journey-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.journey-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-sage);
  opacity: 0.85;
}

.journey-card__duration {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px var(--space-2);
}

.journey-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  line-height: 1.4;
}

.journey-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.65;
}

.journey-card__intro {
  margin: 0 0 var(--space-3);
}

.journey-card__bullets {
  margin: 0;
  padding-inline-start: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.journey-card__bullets li {
  padding-inline-start: var(--space-1);
  line-height: 1.65;
}

.journey-card__steps {
  margin: 0;
  padding-inline-start: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.journey-card__steps li {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.journey-card--challenge {
  border-color: rgba(107, 143, 113, 0.25);
  background: linear-gradient(135deg, var(--color-sage-light) 0%, var(--color-surface) 100%);
}

.journey-card--exercise {
  border-color: rgba(107, 143, 113, 0.2);
}

.journey-card--reflection {
  border-color: rgba(100, 130, 160, 0.22);
  background: linear-gradient(135deg, rgba(100, 130, 160, 0.07) 0%, var(--color-surface) 100%);
}

.journey-card--reminder {
  border-color: rgba(160, 140, 100, 0.22);
  background: linear-gradient(135deg, rgba(160, 140, 100, 0.07) 0%, var(--color-surface) 100%);
}

.journey-card--encouragement {
  border-color: rgba(107, 143, 113, 0.3);
  background: linear-gradient(135deg, var(--color-sage-light) 0%, var(--color-teal-light) 100%);
}

.journey-card--session-end {
  align-self: center;
  text-align: center;
  max-width: 320px;
  border-color: var(--color-border);
  background: var(--color-surface);
  padding: var(--space-7) var(--space-6);
  margin: var(--space-4) auto;
}

.journey-card__session-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-sage-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  color: var(--color-sage);
}

.journey-card__session-icon svg {
  width: 22px;
  height: 22px;
}

.journey-card--session-end .journey-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.journey-card--session-end .journey-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.journey-card__return {
  font-size: var(--text-sm);
  color: var(--color-sage-dark);
  background: var(--color-sage-light);
  border: 1px solid rgba(107, 143, 113, 0.25);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  line-height: 1.6;
  margin-top: var(--space-1);
}

/* RTL alignment for journey cards */
[dir="rtl"] .journey-card { align-self: flex-end; }
[dir="ltr"] .journey-card { align-self: flex-start; }

/* Welcome card inside chat */
.chat-welcome {
  background: linear-gradient(135deg, var(--color-sage-light) 0%, var(--color-teal-light) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  max-width: 480px;
  margin: var(--space-4) auto;
}

.chat-welcome__icon {
  width: 56px;
  height: 56px;
  background: var(--color-surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  color: var(--color-sage);
  box-shadow: var(--shadow-card);
}

.chat-welcome__icon svg { width: 28px; height: 28px; }

.chat-welcome__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.chat-welcome__body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.7;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  animation: messageAppear var(--duration-base) var(--ease-smooth);
}

.typing-indicator__bubble {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  box-shadow: var(--shadow-card);
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-subtle);
  animation: typingBounce 1.3s ease-in-out infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

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

/* Chat input */
.chat-input-area {
  padding: var(--space-3) var(--space-4) var(--space-4);
  background: rgba(244, 246, 244, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  max-width: var(--max-width-chat);
  margin: 0 auto var(--space-2);
  transition:
    border-color var(--duration-fast) var(--ease-smooth),
    box-shadow var(--duration-fast) var(--ease-smooth);
}

.chat-input-wrapper:focus-within {
  border-color: var(--color-teal);
  box-shadow: var(--shadow-input);
}

.chat-input {
  flex: 1;
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: 1.5;
  max-height: 160px;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.chat-input::placeholder {
  color: var(--color-text-subtle);
}

.chat-send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--color-sage);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition:
    background-color var(--duration-fast) var(--ease-smooth),
    transform var(--duration-fast) var(--ease-bounce),
    opacity var(--duration-fast) var(--ease-smooth);
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--color-sage-dark);
  transform: scale(1.05);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.chat-send-btn:disabled {
  background: var(--color-border);
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
  transform: translateX(1px);
}

.chat-input-hint {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  text-align: center;
  line-height: 1.5;
  max-width: var(--max-width-chat);
  margin: 0 auto;
}

/* ── RECOVERY GUIDE ─────────────────────────────────── */
.guide-content {
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-16);
}

.guide-intro {
  padding: var(--space-6);
  background: var(--color-sage-light);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-8);
}

.guide-intro p {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.75;
  font-style: italic;
}

.guide-sections {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.guide-section {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--color-border-soft);
  position: relative;
}

.guide-section:last-of-type { border-bottom: none; }

.guide-section__number {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-regular);
  color: var(--color-sage);
  opacity: 0.4;
  flex-shrink: 0;
  width: 36px;
  line-height: 1.4;
}

.guide-section__body {
  flex: 1;
  min-width: 0;
}

.guide-section__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: var(--space-1);
}

.guide-section__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.guide-section__content p {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.75;
}

.guide-more-placeholder {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
}

/* ── ASSESSMENT SCREEN ──────────────────────────────── */
.assessment-content {
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.assessment-intro {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.assessment-intro__icon {
  width: 72px;
  height: 72px;
  background: var(--color-sage-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-sage);
}

.assessment-intro__icon svg { width: 36px; height: 36px; }

.assessment-intro__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.assessment-intro__body {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.75;
  max-width: 400px;
}

.assessment-placeholder {
  background: var(--color-surface);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--color-text-subtle);
}

.assessment-placeholder__label {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
}

.assessment-placeholder__sub {
  font-size: var(--text-sm);
  opacity: 0.7;
}

.assessment-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}

/* ── DAILY REVIEW ───────────────────────────────────── */
.daily-content {
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-16);
}

.daily-placeholder {
  background: var(--color-surface);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-16) var(--space-6);
  text-align: center;
  color: var(--color-text-subtle);
}

.daily-placeholder__label {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
}

.daily-placeholder__sub {
  font-size: var(--text-sm);
  opacity: 0.7;
}

/* ── BUTTONS ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  transition:
    background-color var(--duration-fast) var(--ease-smooth),
    transform var(--duration-fast) var(--ease-bounce),
    box-shadow var(--duration-fast) var(--ease-smooth);
  cursor: pointer;
  border: none;
  min-width: 200px;
}

.btn--primary {
  background: var(--color-sage);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-btn);
}

.btn--primary:hover {
  background: var(--color-sage-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(107, 143, 113, 0.3);
}

.btn--primary:active {
  transform: translateY(0);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
}

.btn--ghost:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

/* ── TOAST ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--duration-base) var(--ease-smooth),
    transform var(--duration-base) var(--ease-bounce);
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 600px) {

  #screen-home {
    padding: var(--space-10) var(--space-4) var(--space-6);
  }

  .home__inner { gap: var(--space-8); }

  .brand__name { font-size: var(--text-2xl); }

  .home__subtitle { font-size: var(--text-sm); }

  .nav-card { padding: var(--space-4); }

  .nav-card__icon { width: 40px; height: 40px; }
  .nav-card__icon svg { width: 20px; height: 20px; }

  .nav-card__desc { display: none; }

  .chat-messages {
    padding: var(--space-4) var(--space-3);
    gap: var(--space-3);
  }

  .message { max-width: 88%; }

  .message__bubble { padding: var(--space-3) var(--space-4); }

  .chat-input-area { padding: var(--space-3) var(--space-3) var(--space-3); }

  .guide-content,
  .assessment-content,
  .daily-content { padding: var(--space-6) var(--space-4) var(--space-12); }

  .guide-section__number { font-size: var(--text-xl); width: 28px; }

  .btn { min-width: 160px; width: 100%; }
}

@media (min-width: 900px) {
  #screen-home {
    padding-top: var(--space-24);
  }

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

  .nav-card { padding: var(--space-6); }
}

/* ── GLOBAL NAV BAR ─────────────────────────────────── */
#global-bar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  background: rgba(244, 246, 244, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  min-height: 52px;
}

.global-bar__spacer {
  flex: 1;
}

.global-conversations-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-inline-start: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-sage-dark);
  box-shadow: var(--shadow-card);
}

.global-conversations-btn svg {
  width: 19px;
  height: 19px;
}

.global-conversations-btn:hover,
.global-conversations-btn[aria-expanded="true"] {
  background: var(--color-sage-light);
  border-color: var(--color-sage);
}

/* ── LANGUAGE SWITCHER ──────────────────────────────── */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
  box-shadow: var(--shadow-card);
}

.lang-switcher__btn {
  padding: var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth),
              color var(--duration-fast) var(--ease-smooth);
  white-space: nowrap;
  line-height: 1.6;
}

.lang-switcher__btn:hover {
  color: var(--color-text);
}

.lang-switcher__btn[aria-pressed="true"] {
  background: var(--color-sage);
  color: var(--color-text-inverse);
}

/* ── SINGLE-LANGUAGE MODE ───────────────────────────── */
/*
  When a language is active, only that language's text is shown.
  Elements that carry the alternate-language label are hidden.
*/

/* Bilingual subtitles are always the other language — hide in both modes */
.nav-card__subtitle,
.subscreen-header__subtitle,
.guide-section__subtitle {
  display: none;
}

/* Home brand: .brand__name--arabic is always the secondary/alt name */
.brand__name--arabic {
  display: none;
}

/* Chat header: hardcoded bilingual names — show only the active language */
:root[lang="en"] .chat-header__name--arabic { display: none; }
:root[lang="ar"] .chat-header__name:not(.chat-header__name--arabic) { display: none; }

/* ── PRINT ──────────────────────────────────────────── */
@media print {
  .chat-input-area,
  .back-btn,
  .home__nav { display: none; }
}


/* ── Auth Screen ─────────────────────────────────────── */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.5rem;
  gap: 1.5rem;
  max-width: 420px;
  margin: 0 auto;
}
.auth-brand { text-align: center; }
.auth-brand__name { font-size: 1.8rem; font-weight: 700; color: var(--text-primary, #1e293b); margin: 0; }
.auth-brand__tagline { font-size: 0.9rem; color: var(--text-secondary, #64748b); margin: 0.5rem 0 0; }
.auth-tabs { display: flex; gap: 0.5rem; background: var(--bg-secondary, #f1f5f9); border-radius: 10px; padding: 4px; width: 100%; }
.auth-tab { flex: 1; padding: 0.6rem; border: none; background: transparent; border-radius: 8px; font-size: 0.9rem; cursor: pointer; color: var(--text-secondary, #64748b); transition: all 0.2s; }
.auth-tab--active { background: white; color: var(--text-primary, #1e293b); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.auth-form { display: flex; flex-direction: column; gap: 1rem; width: 100%; }
.auth-field { display: flex; flex-direction: column; gap: 0.4rem; }
.auth-field label { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary, #64748b); }
.auth-field input { padding: 0.75rem 1rem; border: 1.5px solid var(--border, #e2e8f0); border-radius: 10px; font-size: 1rem; background: white; transition: border-color 0.2s; }
.auth-field input:focus { outline: none; border-color: var(--accent, #6366f1); }
.auth-submit { padding: 0.85rem; border: none; border-radius: 10px; background: var(--accent, #6366f1); color: white; font-size: 1rem; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.auth-submit:hover:not(:disabled) { opacity: 0.9; }
.auth-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-submit--secondary { background: transparent; color: var(--accent, #6366f1); border: 1.5px solid var(--accent, #6366f1); margin-top: 0.5rem; }
.auth-error { color: #dc2626; font-size: 0.85rem; margin: 0; }
.auth-footer { font-size: 0.8rem; color: var(--text-tertiary, #94a3b8); text-align: center; margin: 0; }

/* ── Welcome screen (post-payment onboarding) ── */
.welcome-icon { display: flex; justify-content: center; margin-bottom: 0.75rem; }
.welcome-icon svg { width: 48px; height: 48px; color: var(--accent, #6366f1); }
.welcome-greeting { font-size: 1.1rem; font-weight: 600; color: var(--text-primary, #1e293b); margin: 0.25rem 0 0; }
.welcome-email { font-size: 0.9rem; color: var(--accent, #6366f1); font-weight: 500; margin: 0.2rem 0 0; min-height: 1.2em; }
.welcome-subtitle { font-size: 0.88rem; color: var(--text-secondary, #64748b); margin: 0.4rem 0 0; }
.welcome-invalid { display: flex; flex-direction: column; gap: 0.75rem; text-align: center; padding: 1rem 0; }
.welcome-invalid__msg { font-size: 0.95rem; color: var(--text-primary, #1e293b); font-weight: 500; margin: 0; }
.welcome-invalid__sub { font-size: 0.85rem; color: var(--text-secondary, #64748b); margin: 0; }


/* =====================================================
   Journey Sidebar — Multiple Recovery Journeys
   ===================================================== */

/* ── Hamburger menu button (chat header) ─────────────── */
.chat-header__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth),
              color var(--duration-fast) var(--ease-smooth);
  flex-shrink: 0;
}

.chat-header__menu-btn:hover {
  background: var(--color-sage-light);
  color: var(--color-sage-dark);
}

/* ── Journey title in header ─────────────────────────── */
.chat-header__journey-title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ── Sidebar backdrop — transparent click-catcher only ── */
.journey-sidebar__backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  opacity: 1;
  pointer-events: none;
}

.journey-sidebar__backdrop.is-visible {
  pointer-events: none;
}

/* ── Sidebar panel ───────────────────────────────────── */
.journey-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 110;
  width: min(320px, 88vw);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  box-shadow: 2px 0 16px rgba(45, 59, 46, 0.10);
  transform: translateX(-100%);
  transition: transform 300ms var(--ease-smooth);
}

.journey-sidebar.is-open {
  transform: translateX(0);
}


/* ── Sidebar header ──────────────────────────────────── */
.journey-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-soft);
  flex-shrink: 0;
}

.journey-sidebar__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0;
}

.journey-sidebar__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth),
              color var(--duration-fast) var(--ease-smooth);
}

.journey-sidebar__close:hover {
  background: var(--color-sage-light);
  color: var(--color-sage-dark);
}

/* ── New journey button ──────────────────────────────── */
.journey-new-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) var(--space-3) var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-sage-dark);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth),
              border-color var(--duration-fast) var(--ease-smooth);
  text-align: left;
  width: calc(100% - var(--space-6));
  flex-shrink: 0;
}

.journey-new-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--color-sage);
}

.journey-new-btn:hover {
  background: var(--color-sage-light);
  border-color: var(--color-sage);
}

/* ── Journey list ────────────────────────────────────── */
.journey-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.journey-list::-webkit-scrollbar { width: 4px; }
.journey-list::-webkit-scrollbar-track { background: transparent; }
.journey-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* ── Journey list item ───────────────────────────────── */
.journey-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth);
  position: relative;
  border: 1px solid transparent;
}

.journey-item:hover {
  background: var(--color-surface-alt);
}

.journey-item.is-active {
  background: var(--color-sage-light);
  border-color: var(--color-border-soft);
}

.journey-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.journey-item__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.journey-item.is-active .journey-item__title {
  color: var(--color-sage-dark);
}

.journey-item__meta {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Conversation options ────────────────────────────── */
.journey-item__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-subtle);
  cursor: pointer;
  flex-shrink: 0;
}

.journey-item__menu-btn:hover,
.journey-item__menu-btn[aria-expanded="true"] {
  background: var(--color-sage-light);
  color: var(--color-sage-dark);
}

.journey-item__menu {
  position: absolute;
  z-index: 5;
  inset-inline-end: var(--space-2);
  top: calc(100% - var(--space-1));
  min-width: 150px;
  padding: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-hover);
}

.journey-item__menu[hidden] {
  display: none;
}

.journey-item__menu button {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  text-align: start;
  cursor: pointer;
}

.journey-item__menu button:hover {
  background: var(--color-sage-light);
}

.journey-item__menu button.is-danger {
  color: #B42318;
}

/* ── Empty state ─────────────────────────────────────── */
.journey-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
}

/* ── Delete confirmation dialog ──────────────────────── */
.delete-dialog {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(45, 59, 46, 0.18);
  padding: var(--space-6);
  max-width: 360px;
  width: calc(100vw - 2rem);
  background: var(--color-surface);
}

.delete-dialog::backdrop {
  background: rgba(45, 59, 46, 0.45);
  backdrop-filter: blur(4px);
}

.delete-dialog h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0 0 var(--space-3);
}

.delete-dialog p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0 0 var(--space-6);
}

.delete-dialog__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

.delete-dialog__cancel {
  padding: var(--space-2) var(--space-5);
  border: 1.5px solid var(--color-border);
  background: transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth),
              border-color var(--duration-fast) var(--ease-smooth);
}

.delete-dialog__cancel:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-text-muted);
}

.delete-dialog__confirm {
  padding: var(--space-2) var(--space-5);
  border: none;
  background: #DC2626;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #FFFFFF;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth);
}

.delete-dialog__confirm:hover {
  background: #B91C1C;
}

/* =====================================================
   PRODUCT HARDENING · accessibility, responsive layout,
   task outcomes, errors, and privacy controls
   ===================================================== */
:root {
  --global-bar-height: 60px;
  --color-text-muted: #526554;
  --color-text-subtle: #607362;
}

#global-bar {
  min-height: calc(var(--global-bar-height) + env(safe-area-inset-top));
  padding-top: calc(var(--space-2) + env(safe-area-inset-top));
}

.back-btn,
.global-conversations-btn,
.journey-sidebar__close,
.privacy-dialog__close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

.lang-switcher__btn {
  min-height: 44px;
  padding-inline: var(--space-4);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
}

.message--user .message__bubble {
  background: #557A5D;
}

.journey-card__steps {
  list-style: decimal;
}

.journey-card__bullets {
  list-style: disc;
}

.journey-card__steps li::marker,
.journey-card__bullets li::marker {
  color: var(--color-sage-dark);
  font-weight: var(--weight-semibold);
}

.current-next-move,
.chat-system-notice {
  width: min(calc(100% - 2rem), var(--max-width-chat));
  margin-inline: auto;
  border-radius: var(--radius-md);
}

.current-next-move {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(107, 143, 113, 0.35);
  background: var(--color-sage-light);
}

.current-next-move__content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.current-next-move__label {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.current-next-move__title {
  color: var(--color-text);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-next-move__button {
  min-height: 44px;
  padding-inline: var(--space-4);
  border: 1px solid var(--color-sage);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-sage-dark);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.chat-system-notice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #D49A4A;
  background: #FFF8EA;
  color: #634514;
}

.chat-system-notice[data-kind="offline"],
.chat-system-notice[data-kind="network"] {
  border-color: #7C93A8;
  background: #F1F6FA;
  color: #31485B;
}

.chat-system-notice__text {
  flex: 1;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.chat-system-notice__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chat-system-notice button {
  min-height: 44px;
  min-width: 44px;
  padding-inline: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  font-size: var(--text-sm);
}

.journey-card__outcomes {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

.journey-card__outcome-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.journey-card__outcomes--completed {
  display: block;
}

.journey-card__outcomes button,
.journey-card__result button {
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.3;
}

.journey-card__outcomes button:hover:not(:disabled),
.journey-card__outcomes button:focus-visible,
.journey-card__outcomes button.is-selected,
.journey-card__result button:hover:not(:disabled),
.journey-card__result button:focus-visible {
  border-color: var(--color-sage);
  background: var(--color-sage-light);
  color: var(--color-sage-dark);
}

.journey-card__outcomes button:disabled,
.journey-card__result button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.journey-card__outcome-followup,
.journey-card__correction-form {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--space-2);
  width: 100%;
}

.journey-card__outcome-followup[hidden],
.journey-card__correction-form[hidden] {
  display: none;
}

.journey-card__outcome-followup label,
.journey-card__correction-form label {
  color: var(--color-text);
  font-weight: 700;
}

.journey-card__outcome-followup textarea,
.journey-card__correction-form textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  line-height: 1.6;
}

.journey-card__outcome-followup textarea:focus,
.journey-card__correction-form textarea:focus {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
}

.journey-card__outcome-actions {
  display: flex;
  gap: var(--space-2);
}

.journey-card__outcome-saved {
  margin: 0;
  color: var(--color-sage-dark);
  font-weight: 700;
}

.journey-item {
  padding: var(--space-1);
  cursor: default;
}

.journey-item__body {
  min-height: 52px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  text-align: inherit;
  align-items: stretch;
}

.journey-item__menu-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.journey-new-btn {
  min-height: 48px;
}

.rename-dialog__label,
.privacy-dialog label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.rename-dialog__input,
.privacy-dialog input {
  width: 100%;
  min-height: 44px;
  margin-bottom: var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
}

.rename-dialog__save {
  min-height: 44px;
  padding-inline: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-sage-dark);
  color: white;
}

.delete-dialog__cancel,
.delete-dialog__confirm {
  min-height: 44px;
}

.age-confirmation {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.5;
  cursor: pointer;
}

.age-confirmation input {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--color-sage-dark);
  flex: 0 0 auto;
}

.privacy-link {
  min-height: 44px;
  padding-inline: var(--space-3);
  color: var(--color-sage-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.privacy-link--inline {
  min-height: auto;
  padding: 0 var(--space-1);
}

.privacy-dialog {
  width: min(560px, calc(100vw - 2rem));
  max-height: min(82dvh, 760px);
  padding: 0;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 18px 60px rgba(45, 59, 46, 0.28);
}

.privacy-dialog::backdrop {
  background: rgba(32, 44, 34, 0.5);
  backdrop-filter: blur(3px);
}

.privacy-dialog__content {
  max-height: min(82dvh, 760px);
  overflow-y: auto;
  padding: var(--space-6);
}

.privacy-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.privacy-dialog__header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
}

.privacy-dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 1.5rem;
}

.privacy-dialog__intro {
  color: var(--color-text-muted);
  line-height: 1.65;
  margin-bottom: var(--space-5);
}

.privacy-dialog__actions {
  display: grid;
  gap: var(--space-2);
}

.privacy-dialog__actions button,
.privacy-dialog__danger button {
  min-height: 46px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  color: var(--color-text);
  text-align: start;
}

.privacy-dialog__actions small {
  margin: calc(-1 * var(--space-1)) var(--space-2) var(--space-3);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.privacy-dialog__danger {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.privacy-dialog__danger summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: #A22C2C;
  cursor: pointer;
  font-weight: var(--weight-semibold);
}

.privacy-dialog__danger p {
  margin-bottom: var(--space-3);
  color: var(--color-text-muted);
}

.privacy-dialog__danger button {
  width: 100%;
  border-color: #C84444;
  background: #FFF2F2;
  color: #8D2020;
  text-align: center;
}

.privacy-dialog__status {
  min-height: 1.5em;
  margin-top: var(--space-4);
  color: var(--color-sage-dark);
  font-size: var(--text-sm);
}

.privacy-dialog__status.is-error {
  color: #9D2525;
}

.chat-input-area {
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
}

.journey-sidebar {
  top: calc(var(--global-bar-height) + env(safe-area-inset-top));
  bottom: 0;
  z-index: 180;
}

[dir="ltr"] .journey-sidebar {
  left: 0;
  right: auto;
  border-right: 1px solid var(--color-border);
  border-left: 0;
  transform: translateX(-100%);
}

[dir="rtl"] .journey-sidebar {
  right: 0;
  left: auto;
  border-left: 1px solid var(--color-border);
  border-right: 0;
  transform: translateX(100%);
}

[dir="ltr"] .journey-sidebar.is-open,
[dir="rtl"] .journey-sidebar.is-open {
  transform: translateX(0);
}

#app {
  transition:
    padding-left 300ms var(--ease-smooth),
    padding-right 300ms var(--ease-smooth);
}

@media (min-width: 721px) {
  [dir="ltr"] body.sidebar-open #app {
    padding-left: min(320px, 88vw);
    padding-right: 0;
  }

  [dir="rtl"] body.sidebar-open #app {
    padding-right: min(320px, 88vw);
    padding-left: 0;
  }
}

@media (max-width: 720px) {
  body.sidebar-open #app {
    padding-left: 0;
    padding-right: 0;
  }

  .journey-sidebar {
    width: min(300px, 78vw);
    box-shadow: 0 10px 36px rgba(45, 59, 46, 0.22);
  }

  .message,
  .journey-card {
    max-width: 92%;
  }

  .current-next-move,
  .chat-system-notice {
    width: calc(100% - 1.5rem);
  }

  .current-next-move {
    align-items: stretch;
  }

  .journey-card__outcome-buttons {
    grid-template-columns: 1fr;
  }

  .privacy-dialog__content {
    padding: var(--space-5);
  }
}

/* Budget launch: keep the original design while bounding each active screen.
   Hidden screens never contribute scroll size; only the transcript scrolls in chat. */
html { height: 100%; }
body {
  height: var(--app-viewport-height, 100dvh);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#global-bar { position: relative; flex: 0 0 auto; }
#app { flex: 1 1 0; height: auto; min-height: 0; overflow: hidden; }
.screen:not(.screen--active) { display: none !important; }
.screen--active { position: relative; inset: auto; height: 100%; min-height: 0; overflow-y: auto; }
#screen-assessment.screen--active { display: flex; min-height: 0; height: 100%; overflow: hidden; }
.chat-header, .chat-input-area, .current-next-move, .chat-system-notice { flex: 0 0 auto; }
.chat-header { position: relative; min-width: 0; }
.chat-header__brand { min-width: 0; }
.chat-header__journey-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-messages { flex: 1 1 0; min-height: 0; overscroll-behavior: contain; overflow-wrap: anywhere; }
.chat-messages > * { flex-shrink: 0; }
.chat-input-area { position: relative; z-index: 60; }
.chat-input { min-width: 0; max-height: min(160px, 25dvh); }
.chat-new-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-sage-dark); font-size: var(--text-sm); white-space: nowrap; flex-shrink: 0; }
.chat-new-btn > span:first-child { font-size: 22px; line-height: 1; }
.chat-new-btn:hover { background: var(--color-sage-light); }
.conversation-loading, .conversation-empty { margin: auto; padding: var(--space-6); text-align: center; color: var(--color-text-muted); max-width: 480px; }
.app-startup { height: 100%; display: flex; align-items: center; justify-content: center; padding: var(--space-6); text-align: center; color: var(--color-text-muted); }
.conversation-empty button { margin: var(--space-3) 4px 0; min-height: 44px; border: 1px solid var(--color-border); padding: 8px 14px; border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-sage-dark); }
.journey-card__saved-note { margin-top: var(--space-3); padding: var(--space-3); border-inline-start: 3px solid var(--color-sage); background: var(--color-sage-light); border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.journey-card__saved-note-label { display: block; margin-bottom: var(--space-1); font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.journey-card__original-note { margin-block: var(--space-2); font-size: var(--text-sm); overflow-wrap: anywhere; }
.journey-card__original-note p { white-space: pre-wrap; }
.journey-card__original-note summary { cursor: pointer; color: var(--color-text-muted); }
.journey-card__correction-open { margin-top: var(--space-2); }
.journey-card__correction-form { margin-top: var(--space-3); }
.journey-card__correction-hint { color: var(--color-text-muted); font-size: var(--text-sm); margin: 0; }
.journey-card__correction-error { color: #b42318; font-size: var(--text-sm); margin: 0; }
.journey-card__results { display: grid; gap: var(--space-3); }
.journey-card__results-label { margin-block: var(--space-3) var(--space-2); color: var(--color-text-muted); font-size: var(--text-sm); }
.journey-card__results > .journey-card__result { padding-block: var(--space-3); border-top: 1px solid var(--color-border); }
.journey-card__result-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); color: var(--color-text-muted); font-size: var(--text-xs); }
.journey-card__feedback-resume { margin-top: var(--space-3); min-height: 44px; padding: 8px 12px; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: var(--radius-sm); color: var(--color-sage-dark); }
dialog.delete-dialog, dialog.privacy-dialog { position: fixed; inset: 0; margin: auto; max-height: calc(var(--app-viewport-height, 100dvh) - 2rem); overflow-y: auto; overscroll-behavior: contain; }
.privacy-dialog__content { max-height: calc(var(--app-viewport-height, 100dvh) - 2rem); }
.privacy-dialog__header { position: sticky; top: 0; padding-top: var(--space-3); padding-bottom: var(--space-3); background: var(--color-surface); z-index: 1; }
.privacy-dialog__header h2 { min-width: 0; overflow-wrap: anywhere; }
.billing-plan { margin-bottom: var(--space-4); padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-alt); }
.billing-test-badge { display: inline-block; padding: 3px 9px; background: var(--color-warning-bg); color: #805313; border-radius: var(--radius-full); font-size: var(--text-xs); }
.billing-price { font-size: var(--text-xl); font-weight: var(--weight-semibold); margin-top: var(--space-3); }
.billing-plan .small { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: var(--space-2); }
@media (max-width: 520px) {
  .chat-header { gap: var(--space-2); padding-inline: var(--space-3); }
  .chat-new-btn { padding-inline: 10px; }
  .chat-header__status .status-label { display: none; }
  .chat-header__journey-title { font-size: var(--text-base); }
  .chat-input-hint { font-size: 11px; }
}
