/* ============================================================
   ClearThread — Design System
   Concept: The Writing Room — intimate, literary, unhurried
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
  --bg:            #f5f1ea;
  --bg-subtle:     #ede8de;
  --surface:       #faf8f4;
  --surface-raise: #ffffff;
  --border:        #ddd6ca;
  --border-focus:  #6a8a6e;

  --accent:        #5a7060;   /* sage */
  --accent-light:  #e4ede6;
  --accent-hover:  #435548;
  --accent-fg:     #ffffff;

  --warm:          #7a6548;
  --warm-light:    #ede5d8;

  --text:          #1c1a17;
  --text-secondary:#544f48;
  --text-muted:    #8c867e;
  --text-on-accent:#ffffff;

  /* User messages: warm sage-tinted green */
  --user-bubble:   #d6e4d8;
  /* Therapist: crisp white card */
  --agent-surface: #ffffff;
  --therapist-accent: #5a7060;

  --danger:        #7a3530;
  --danger-light:  #f5e7e5;
  --success:       #3a6b50;
  --warning-bg:    #fdf3e3;
  --warning-border:#c9a855;

  /* Radii — one system: 8 / 14 / 20 / pill */
  --r-sm:  8px;
  --r:     14px;
  --r-lg:  20px;
  --r-xl:  28px;

  /* Shadows */
  --shadow-xs: 0 1px 3px rgba(28,26,23,0.06);
  --shadow-sm: 0 2px 10px rgba(28,26,23,0.08);
  --shadow:    0 4px 24px rgba(28,26,23,0.10);
  --shadow-lg: 0 10px 48px rgba(28,26,23,0.13);

  /* Typography */
  --font-display: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --font-body:    'Optima', 'Candara', 'Gill Sans Nova', 'Gill Sans MT', Calibri, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; }
body {
  height: 100%;
  visibility: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea { font-family: inherit; font-size: inherit; }
input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ---- Logo ---- */
.logo-wordmark {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: normal;
  letter-spacing: 0.015em;
  color: var(--text);
}

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 160ms var(--ease), transform 100ms var(--ease), box-shadow 160ms;
  box-shadow: 0 1px 3px rgba(90,112,96,0.28);
}
.btn-primary:hover  { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(90,112,96,0.32); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:hover  { text-decoration: none; }
.btn-primary.btn-full { width: 100%; padding: 13px 22px; font-size: 0.95rem; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  transition: background 130ms, color 130ms;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.btn-ghost.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-ghost.btn-xs { padding: 4px 8px; font-size: 0.75rem; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--danger);
  color: white;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  transition: background 150ms, transform 100ms;
}
.btn-danger:hover  { background: #632c28; }
.btn-danger:active { transform: scale(0.98); }
.btn-danger.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ---- Form components ---- */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-group label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.field-hint {
  font-weight: normal;
  color: var(--text-muted);
  font-size: 0.78rem;
}
input[type="text"],
input[type="email"],
input[type="password"] {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-raise);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 150ms;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--border-focus);
  outline: none;
}
input::placeholder { color: var(--text-muted); opacity: 0.85; }

.form-error {
  padding: 10px 14px;
  background: var(--danger-light);
  border: 1px solid #ddb0ab;
  border-radius: var(--r-sm);
  color: var(--danger);
  font-size: 0.875rem;
  animation: fadeSlideIn 200ms var(--ease);
}
.form-success {
  padding: 10px 14px;
  background: #e6f0e9;
  border: 1px solid #9fccaa;
  border-radius: var(--r-sm);
  color: var(--success);
  font-size: 0.875rem;
}

/* ---- Auth Page — Split layout ---- */
.page-auth {
  display: grid;
  grid-template-columns: 5fr 7fr;
  min-height: 100dvh;
}

/* Brand / left panel */
.auth-brand {
  background: #1b1814;
  display: flex;
  flex-direction: column;
  padding: 52px 52px 56px;
  position: relative;
  overflow: hidden;
}

/* Subtle paper grain */
.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.04;
  pointer-events: none;
}
.auth-brand > * { position: relative; }

.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #6a8a6e;
  margin-bottom: auto;
}
.auth-brand-logo .logo-wordmark {
  color: #c5bdb0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.auth-brand-body {
  padding-bottom: 4px;
}

.auth-brand-quote {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: normal;
  color: #ddd5c8;
  line-height: 1.5;
  margin-bottom: 22px;
  font-style: italic;
  letter-spacing: 0.01em;
}

.auth-brand-caption {
  font-size: 0.72rem;
  color: #5a5248;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: var(--font-body);
}

/* Form / right panel */
.auth-form-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 72px;
  background: var(--bg);
}

.auth-form-inner {
  width: 100%;
  max-width: 360px;
  animation: fadeSlideUp 400ms var(--ease-out);
}

.auth-form-header {
  margin-bottom: 32px;
}

.auth-form-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: normal;
  color: var(--text);
  margin-bottom: 5px;
  line-height: 1.25;
}

.auth-form-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-display);
}

/* Tabs */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 1.5px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 9px 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition: color 150ms, border-color 150ms;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-tab:hover:not(.active) { color: var(--text-secondary); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-form.hidden { display: none; }

/* Language toggle */
.lang-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.lang-opt {
  flex: 1;
  padding: 9px 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: transparent;
  transition: background 150ms, color 150ms;
}
.lang-opt.active  { background: var(--accent); color: white; }
.lang-opt:hover:not(.active) { background: var(--bg-subtle); }

/* ToS */
.tos-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.tos-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}
.tos-link { color: var(--accent); }

/* ---- App shell ---- */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ---- App header ---- */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  height: 56px;
  background: var(--surface-raise);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  z-index: 10;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
}
.header-logo:hover { text-decoration: none; }

.header-nav { flex: 1; display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  transition: background 130ms, color 130ms;
}
.nav-link:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.user-name { font-size: 0.85rem; color: var(--text-secondary); }

/* ---- Crisis card ---- */
.crisis-card {
  flex-shrink: 0;
  background: var(--warning-bg);
  border-bottom: 2px solid var(--warning-border);
  animation: fadeSlideIn 250ms var(--ease);
}
.crisis-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 28px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}
.crisis-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.crisis-text { flex: 1; font-size: 0.88rem; line-height: 1.65; white-space: pre-line; }
.crisis-dismiss {
  flex-shrink: 0;
  padding: 4px;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  transition: color 130ms, background 130ms;
}
.crisis-dismiss:hover { color: var(--text); background: rgba(0,0,0,0.06); }

/* ---- Chat page ---- */
.chat-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0 24px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* Welcome state */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 32px 48px;
  text-align: center;
  animation: fadeSlideUp 500ms var(--ease-out);
}
.welcome-inner { max-width: 320px; }

.welcome-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 22px;
  color: var(--accent);
  opacity: 0.55;
}

.welcome-greeting {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--text-secondary);
  font-weight: normal;
  margin-bottom: 10px;
  font-style: italic;
}
.welcome-sub { font-size: 0.875rem; color: var(--text-muted); line-height: 1.7; }

/* ---- Messages — Literary Transcript ---- */
.message-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 28px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  animation: fadeSlideUp 200ms var(--ease);
}

/* Space between consecutive messages from same side */
.message-row + .message-row { padding-top: 4px; }

/* Therapist / agent */
.message-row--agent,
.message-row--therapist {
  align-items: flex-start;
}

/* User messages push right */
.message-row--user {
  align-items: flex-end;
}

/* Group user messages (not me, not therapist) */
.message-row--group-user {
  align-items: flex-start;
}

.message-author {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 4px;
}
.message-author--therapist { color: var(--therapist-accent); }
.message-author--user { color: var(--warm); }

/* Message text container */
.message-bubble {
  max-width: min(560px, 88%);
  padding: 13px 18px;
  border-radius: var(--r);
  font-size: 0.95rem;
  line-height: 1.7;
  position: relative;
}

/* Therapist messages: serif card */
.message-row--agent .message-bubble,
.message-row--therapist .message-bubble {
  background: var(--agent-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.8;
  color: var(--text);
  border-radius: var(--r);
  max-width: min(640px, 92%);
}

/* User messages: colored pill */
.message-row--user .message-bubble {
  background: var(--user-bubble);
  border-radius: var(--r);
  border-bottom-right-radius: 4px;
  color: var(--text);
}

/* Group participants */
.message-row--group-user .message-bubble {
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Streaming cursor */
.streaming-cursor .message-text::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 1.1s ease-in-out infinite;
  border-radius: 1px;
}

/* Tool indicator — "the therapist is thinking" */
.tool-indicator {
  max-width: 800px;
  margin: 0 auto;
  padding: 6px 32px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-display);
  animation: fadeSlideIn 200ms var(--ease);
}
.tool-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}
.tool-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
}
.tool-dot:nth-child(1) { animation: pulseDot 1.6s ease-in-out 0.0s infinite; }
.tool-dot:nth-child(2) { animation: pulseDot 1.6s ease-in-out 0.2s infinite; }
.tool-dot:nth-child(3) { animation: pulseDot 1.6s ease-in-out 0.4s infinite; }

/* ---- Chat footer ---- */
.chat-footer {
  flex-shrink: 0;
  background: var(--surface-raise);
  border-top: 1px solid var(--border);
  padding: 12px 28px 16px;
}

.chat-input-wrap {
  max-width: 800px;
  margin: 0 auto;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 8px 12px 8px 16px;
  transition: border-color 180ms, box-shadow 180ms;
}
.chat-input-row:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(106,138,110,0.10);
}

.chat-textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
  max-height: 140px;
  overflow-y: auto;
  padding: 3px 0;
}
.chat-textarea:focus { outline: none; }
.chat-textarea::placeholder { color: var(--text-muted); opacity: 0.8; }

.chat-send-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border-radius: var(--r-sm);
  transition: background 130ms, transform 90ms, opacity 130ms;
}
.chat-send-btn:hover:not(:disabled)  { background: var(--accent-hover); }
.chat-send-btn:active:not(:disabled) { transform: scale(0.93); }
.chat-send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.chat-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 2px;
}
.footer-hint { font-size: 0.72rem; color: var(--text-muted); }

/* ---- Groups page ---- */
.groups-main {
  flex: 1;
  overflow-y: auto;
  padding: 44px 28px;
}
.groups-content { max-width: 720px; margin: 0 auto; }

.page-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: normal;
  color: var(--text);
  line-height: 1.25;
}
.page-subtitle {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 480px;
  line-height: 1.65;
}

.groups-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.create-group-panel {
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  animation: fadeSlideUp 240ms var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.invite-panel {
  background: var(--accent-light);
  border: 1px solid #b0c8b3;
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  animation: fadeSlideUp 240ms var(--ease-out);
}

.invite-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.invite-input { flex: 1; min-width: 200px; }

.invite-result {
  margin-top: 10px;
  padding: 9px 13px;
  border-radius: var(--r-sm);
  font-size: 0.84rem;
  line-height: 1.5;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: normal;
  margin-bottom: 16px;
  color: var(--text);
}
.panel-hint { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.6; }

.create-group-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Groups list */
.groups-list { display: flex; flex-direction: column; gap: 10px; }
.groups-loading { padding: 48px; display: flex; justify-content: center; }

.group-card {
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 180ms, transform 140ms;
  animation: fadeSlideUp 230ms var(--ease);
}
.group-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.group-card-info { flex: 1; min-width: 0; }
.group-card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: normal;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-card-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }
.group-card-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge--pending { background: #ede8da; color: #7a6230; }
.badge--active  { background: var(--accent-light); color: var(--accent-hover); }
.badge--closed  { background: var(--bg-subtle); color: var(--text-muted); }

/* Empty state */
.groups-empty {
  padding: 64px 24px;
  text-align: center;
}
.empty-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 20px;
  color: var(--accent);
  opacity: 0.45;
}
.empty-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: normal;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-style: italic;
}
.empty-sub { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 24px; line-height: 1.7; }

/* ---- Group room ---- */
.app-header--room { gap: 12px; }
.room-info { flex: 1; min-width: 0; }
.room-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: normal;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-members {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1px;
}
.member-chip {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-radius: 99px;
  padding: 2px 8px;
}

.room-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.conn-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  color: var(--text-muted);
}
.conn-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 300ms;
}
.conn-status.connected    .conn-dot   { background: var(--success); }
.conn-status.connected    .conn-label { color: var(--success); }
.conn-status.disconnected .conn-dot   { background: var(--danger); }
.conn-status.disconnected .conn-label { color: var(--danger); }

/* Session ended overlay */
.session-ended-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245,241,234,0.90);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}
.session-ended-card {
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 52px 44px;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideUp 360ms var(--ease-out);
}
.session-ended-card svg { color: var(--accent); margin-bottom: 18px; opacity: 0.7; }
.session-ended-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: normal;
  margin-bottom: 12px;
  font-style: italic;
}
.session-ended-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.7;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,26,23,0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn 160ms ease;
  backdrop-filter: blur(3px);
}
.modal-overlay[hidden] { display: none; }

.modal-card {
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 30px 34px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideUp 240ms var(--ease-out);
}
.modal-card--wide { max-width: 520px; }

.modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: normal;
  margin-bottom: 16px;
}
.modal-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.65;
  margin-bottom: 22px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.consent-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}
.consent-disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ---- Recovery key box ---- */
.recovery-key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin: 12px 0;
}

.recovery-key-value {
  flex: 1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  word-break: break-all;
  color: var(--text);
  user-select: all;
}

/* ---- Loading dots ---- */
.loading-dots { display: flex; gap: 6px; align-items: center; }
.loading-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulseDot 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ---- Animations ---- */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  45%, 55%  { opacity: 0; }
}
@keyframes pulseDot {
  0%, 80%, 100% { transform: scale(0.65); opacity: 0.4; }
  40%           { transform: scale(1);    opacity: 1; }
}

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

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .page-auth {
    grid-template-columns: 1fr;
  }
  .auth-brand {
    padding: 36px 28px 40px;
    min-height: auto;
  }
  .auth-brand-logo { margin-bottom: 28px; }
  .auth-brand-quote { font-size: 1.3rem; }
  .auth-form-side { padding: 40px 24px 48px; justify-content: flex-start; }
  .auth-form-inner { animation: none; }
}

@media (max-width: 600px) {
  .app-header { padding: 0 16px; }
  .chat-footer { padding: 10px 16px 14px; }
  .message-row { padding: 5px 16px; }
  .groups-main { padding: 28px 16px; }
  .groups-header-row { flex-direction: column; }
  .room-info { display: none; }
  .auth-form-side { padding: 32px 20px 40px; }
}
