/* ================================================
   Luma Design System — Premium Empathetic UI
   ================================================ */

/* --- CSS Variables / Tokens --- */
:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #4834D4;
  --primary-glow: rgba(108,92,231,0.25);
  --accent: #00CEC9;
  --accent-light: #81ECEC;
  --warm: #FDCB6E;
  --bg-page: linear-gradient(160deg, #FEFCFF 0%, #F3EEFF 50%, #EDF2FF 100%);
  --bg: #F8F7FF;
  --bg-card: rgba(255,255,255,0.88);
  --bg-chat: #FFFFFF;
  --text: #2D3436;
  --text-secondary: #636E72;
  --text-muted: #B2BEC3;
  --border: rgba(108,92,231,0.1);
  --border-hover: rgba(108,92,231,0.25);
  --border-light: #F3F4F6;
  --success: #00B894;
  --warning: #FDCB6E;
  --danger: #FF7675;
  --danger-light: #FFF0F0;
  /* --- Distress scale (universal green→red, both light & dark) --- */
  --d-calm: #00B894;       --d-calm-bg: rgba(0,184,148,0.12);
  --d-concerned: #FDCB6E;  --d-concerned-bg: rgba(253,203,110,0.16);
  --d-distressed: #FF9F43; --d-distressed-bg: rgba(255,159,67,0.16);
  --d-critical: #FF7675;   --d-critical-bg: rgba(255,118,117,0.16);
  --shadow-sm: 0 2px 8px rgba(108,92,231,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 24px rgba(108,92,231,0.1), 0 2px 6px rgba(0,0,0,0.03);
  --shadow-lg: 0 8px 40px rgba(108,92,231,0.14), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 60px rgba(108,92,231,0.18);
  --shadow-glow: 0 0 30px rgba(108,92,231,0.2), 0 0 60px rgba(108,92,231,0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  --font: 'Heebo', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.3s var(--ease);
}

/* --- Dark Mode Tokens (Serene Blue palette) --- */
body.dark-mode {
  --primary: #3B82C4;
  --primary-light: #93C5FD;
  --primary-dark: #1E6FB5;
  --primary-glow: rgba(59,130,196,0.3);
  --accent: #5EC4B6;
  --accent-light: #8FD9CE;
  --bg-page: linear-gradient(160deg, #050D15 0%, #0A1525 50%, #071214 100%);
  --bg: #07121C;
  --bg-card: rgba(12,24,38,0.92);
  --bg-chat: #091624;
  --text: #E6EEF6;
  --text-secondary: #8AA4BC;
  --text-muted: #51677D;
  --border: rgba(59,130,196,0.18);
  --border-hover: rgba(59,130,196,0.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(59,130,196,0.35);
}

/* --- High Contrast --- */
.high-contrast {
  --bg-page: #000;
  --bg: #000;
  --bg-card: #111;
  --bg-chat: #000;
  --text: #FFF;
  --text-secondary: #DDD;
  --border: #FFF;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);  /* solid fallback; gradient rendered via body::before */
  color: var(--text);
  direction: rtl;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
}


/* Fixed page background — promoted to own compositor layer (no scroll repaint) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  z-index: -1;
  pointer-events: none;
}

/* --- Accessibility --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-card);  /* no backdrop-filter: sticky header repaints every frame */
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light), var(--accent));
  color: #fff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 4px 16px var(--primary-glow);
  position: relative;
  overflow: hidden;
}
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.3));
  border-radius: inherit;
}

.header-title h1 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.emotion-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(108,92,231,0.08);
  color: var(--primary-dark);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.emotion-badge.is-negative {
  background: rgba(255,118,117,0.12);
  color: #b23a39;
  border-color: rgba(255,118,117,0.3);
}

.emotion-badge.is-positive {
  background: rgba(0,184,148,0.14);
  color: #08745f;
  border-color: rgba(0,184,148,0.26);
}

.trust-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(0,184,148,0.1), rgba(0,206,201,0.08));
  color: var(--success);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid rgba(0,184,148,0.15);
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: rgba(108,92,231,0.06);
  color: var(--primary);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.icon-btn.recording {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
  animation: pulse-record 1.5s ease-in-out infinite;
}
@keyframes pulse-record {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,118,117,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255,118,117,0); }
}

/* --- Main Layout --- */
.app-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 24px 100px;
}

/* --- Persona Bar --- */
.persona-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.persona-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.persona-bar select {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
}
.persona-bar select:hover {
  border-color: var(--primary-light);
}

/* --- Chat Container --- */
.chat-container {
  position: relative;
  margin-bottom: 12px;
}

#chat {
  min-height: 440px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 28px 24px;
  background: var(--bg-chat);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  scroll-behavior: smooth;
  transition: background var(--transition), border-color var(--transition);
  /* Perf: isolate scroll repaint to this container */
  contain: layout style;
  will-change: scroll-position;
}

#chat::-webkit-scrollbar {
  width: 6px;
}
#chat::-webkit-scrollbar-track {
  background: transparent;
}
#chat::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* --- Chat Messages --- */
.msg {
  max-width: 78%;
  padding: 14px 20px;
  margin: 10px 0;
  border-radius: 20px;
  font-size: 0.95rem;
  line-height: 1.7;
  animation: msgSlideIn 0.35s var(--ease);
  position: relative;
  word-wrap: break-word;
  /* Perf: each message is a self-contained paint unit */
  contain: layout style;
}

@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg.user {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 6px;
  box-shadow: 0 3px 14px var(--primary-glow);
}

.msg.bot {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  margin-right: auto;
  margin-left: 0;
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
  border-right: 3px solid var(--primary-light);
}

.critical {
  background: var(--danger-light) !important;
  color: var(--danger) !important;
  border: 1px solid var(--danger) !important;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}

/* --- Input Area --- */
.input-area {
  position: relative;
  margin-bottom: 20px;
}

.input-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 14px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition), box-shadow var(--transition);
  backdrop-filter: blur(4px);
}

.input-controls:focus-within {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

.input-controls input[type="text"] {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  padding: 12px 10px;
  outline: none;
  min-width: 0;
}
.input-controls input[type="text"]::placeholder {
  color: var(--text-muted);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Radial (burst) menu ─────────────────────────────── */
.radial-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  isolation: isolate; /* own stacking context */
}

/* The trigger pill */
.radial-trigger {
  position: relative;
  z-index: 2;
}
.radial-trigger[aria-expanded="true"],
.radial-menu-wrap.open .radial-trigger {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* ── Sparkle trigger icon ─── */
.radial-svg {
  display: block;
  transition: transform 0.4s var(--ease);
}
.rs-star {
  transition: filter 0.3s var(--ease), transform 0.4s var(--ease);
  transform-origin: center;
  transform-box: fill-box;
}
.rs-glint {
  opacity: 0;
  transform-origin: center;
  transform-box: fill-box;
  transition: opacity 0.3s 0.15s var(--ease), transform 0.4s 0.1s var(--ease);
  transform: scale(0);
}

/* open: star spins + glows + glints pop */
.radial-menu-wrap.open .radial-svg   { transform: rotate(20deg) scale(1.15); }
.radial-menu-wrap.open .rs-star      { filter: drop-shadow(0 0 5px var(--primary-light)); }
.radial-menu-wrap.open .rs-glint     { opacity: 1; transform: scale(1); }

/* subtle idle pulse on trigger */
@keyframes radial-pulse {
  0%,100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50%      { box-shadow: 0 0 0 6px rgba(108,92,231,0); }
}
.radial-trigger:hover {
  animation: radial-pulse 1.4s var(--ease) infinite;
}

/* Items container — sits above the input bar */
.radial-items {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 50%;
  transform: translateX(50%);
  pointer-events: none;
  width: 0;
  height: 0;
  z-index: 500;
}

/* Invisible bridge fills the gap between trigger and items
   so moving the mouse upward doesn't leave the hover zone  */
.radial-items::before {
  content: '';
  position: absolute;
  bottom: -14px;      /* covers the 14px gap */
  left: -120px;
  right: -120px;
  height: 14px;
  background: transparent;
  pointer-events: none; /* bridge is transparent, items get events */
}

/* Each radial item: hidden by default */
.radial-item {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0;
  box-shadow: var(--shadow-md);
  transition:
    transform 0.35s var(--ease),
    opacity 0.3s var(--ease),
    background 0.2s,
    color 0.2s,
    border-color 0.2s;

  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
}

.radial-item svg { pointer-events: none; }

.radial-item:hover,
.radial-item:focus-visible {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 18px var(--primary-glow);
}

/* file-upload-btn inside radial */
.radial-item.file-upload-btn { cursor: pointer; }
.radial-item.file-upload-btn input[type="file"] {
  display: none !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ── OPEN STATE (JS adds .open class) ── */
.radial-menu-wrap.open .radial-items {
  pointer-events: all;
}

/* 5-item symmetric arc above trigger */
.radial-menu-wrap.open .radial-item[style*="--i:0"] {
  transform: translate(calc(-50% + -90px), calc(-50% - 38px)) scale(1);
  opacity: 1; pointer-events: all; transition-delay: 0s;
}
.radial-menu-wrap.open .radial-item[style*="--i:1"] {
  transform: translate(calc(-50% + -52px), calc(-50% - 68px)) scale(1);
  opacity: 1; pointer-events: all; transition-delay: 0.045s;
}
.radial-menu-wrap.open .radial-item[style*="--i:2"] {
  transform: translate(calc(-50% + 0px),   calc(-50% - 80px)) scale(1);
  opacity: 1; pointer-events: all; transition-delay: 0.09s;
}
.radial-menu-wrap.open .radial-item[style*="--i:3"] {
  transform: translate(calc(-50% + 52px),  calc(-50% - 68px)) scale(1);
  opacity: 1; pointer-events: all; transition-delay: 0.135s;
}
.radial-menu-wrap.open .radial-item[style*="--i:4"] {
  transform: translate(calc(-50% + 90px),  calc(-50% - 38px)) scale(1);
  opacity: 1; pointer-events: all; transition-delay: 0.18s;
}

/* Tooltip labels */
.radial-item::after {
  content: attr(title);
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.7rem;
  font-family: var(--font);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s 0.1s;
}
.radial-item:hover::after { opacity: 1; }

.file-upload-btn {
  cursor: pointer;
}
.file-upload-btn input[type="file"] {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  position: absolute !important;
  pointer-events: none !important;
}
/* ── end radial menu ─────────────────────────────────── */


.send-btn {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  box-shadow: 0 3px 14px var(--primary-glow);
  flex-shrink: 0;
}
.send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px var(--primary-glow);
}
.send-btn:active {
  transform: scale(0.96);
}

/* --- Chart Section --- */
.chart-section {
  margin: 20px 0;
  display: none;
}
.chart-section canvas {
  width: 100% !important;
  height: auto !important;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* --- Panels Grid --- */
.panels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 24px 0;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition);
  backdrop-filter: blur(3px);
}
.panel:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}
.panel[open] {
  box-shadow: var(--shadow-md);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  transition: background var(--transition);
  list-style: none;
}
.panel-header::-webkit-details-marker {
  display: none;
}
.panel-header::after {
  content: "›";
  margin-right: auto;
  margin-left: 0;
  transition: transform var(--transition);
  color: var(--text-muted);
  font-size: 1.2rem;
  font-weight: 300;
}
details[open] > .panel-header::after {
  transform: rotate(90deg);
}
.panel-header:hover {
  background: var(--bg);
}

.panel-icon {
  font-size: 1.2rem;
}

.panel-body {
  padding: 0 18px 18px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.panel-body > * + * {
  margin-top: 10px;
}

/* --- Buttons --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 26px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 3px 14px var(--primary-glow);
}
.btn-primary:hover {
  box-shadow: 0 6px 24px var(--primary-glow);
  transform: translateY(-2px);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: rgba(108,92,231,0.06);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover {
  border-color: var(--primary-light);
  background: rgba(108,92,231,0.12);
  transform: translateY(-1px);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-full {
  width: 100%;
}

/* --- Settings Bar --- */
.settings-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  backdrop-filter: blur(3px);
}

.settings-bar input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.settings-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px var(--primary-glow);
}

/* --- Modal (Onboarding) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10,10,18,0.75);
  backdrop-filter: blur(4px) saturate(1.2);
  -webkit-backdrop-filter: blur(4px) saturate(1.2);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 20px;
}

.modal-card {
  background: var(--bg-card);
  max-width: 440px;
  width: 92%;
  padding: 40px 32px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: modalIn 0.5s var(--ease);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(24px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-logo {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light), var(--accent));
  color: #fff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 34px;
  margin: 0 auto 20px;
  box-shadow: 0 6px 24px var(--primary-glow);
  position: relative;
}
.modal-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.25));
  border-radius: inherit;
}

.modal-card h2 {
  font-size: 1.7rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 18px;
}

.onboarding-tips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(108,92,231,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-secondary);
  text-align: right;
  transition: all var(--transition);
}
.tip-item:hover {
  background: rgba(108,92,231,0.08);
  border-color: var(--border-hover);
}
.tip-item span {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.onboarding-form .form-group {
  margin-bottom: 14px;
  text-align: right;
}

.onboarding-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.onboarding-form select {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
}
.onboarding-form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  padding: 18px 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(4px);
}
.app-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.app-footer a:hover {
  text-decoration: underline;
}

/* --- Notification Toast --- */
.notification {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  padding: 14px 32px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 1000;
  font-size: 0.9rem;
  animation: toastIn 0.3s var(--ease);
  backdrop-filter: blur(4px);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Breathing Animation --- */
.breathing {
  animation: breathing 6s ease-in-out infinite;
}
@keyframes breathing {
  0% { transform: scale(1.0); }
  40% { transform: scale(1.04); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1.0); }
}

/* --- Textarea & Forms --- */
textarea {
  width: 100%;
  max-width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  resize: vertical;
  transition: all var(--transition);
}
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

/* --- Admin hidden section in main page --- */
#adminDashboard {
  margin-top: 32px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
#adminDashboard h2, #adminDashboard h3 {
  color: var(--text);
  margin-bottom: 12px;
}

/* --- Generic Helpers --- */
.soft-shadow { box-shadow: var(--shadow-sm); }
.no-allcaps { text-transform: none !important; }

/* --- TTS Toggle (now lives inside radial menu as #ttsToggleRadial) --- */
.radial-item.active {
  background: rgba(108,92,231,0.15);
  color: var(--primary);
  border-color: var(--primary-light);
}
.radial-item.active:hover {
  background: var(--primary);
  color: #fff;
}
/* old external tts-toggle — hidden in case JS still references it */
.tts-toggle { display: none !important; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .app-header {
    padding: 12px 18px;
  }
  .header-subtitle {
    display: none;
  }
  .trust-badge {
    display: none;
  }
  .app-main {
    padding: 18px 14px 80px;
  }
  #chat {
    min-height: 300px;
    max-height: 50vh;
    padding: 18px 16px;
  }
  .msg {
    max-width: 90%;
  }
  .panels-grid {
    grid-template-columns: 1fr;
  }
  .onboarding-tips {
    grid-template-columns: 1fr;
  }
  .input-actions {
    gap: 2px;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
  }
  .send-btn {
    width: 42px;
    height: 42px;
  }
  .modal-card {
    padding: 28px 20px;
  }
}
  .trust-badge {
    display: none;
  }
  .settings-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ================================================
   Avatar Section Styles
   ================================================ */

/* --- Section wrapper --- */
.avatar-section {
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

/* --- LiveAvatar embed --- */
.avatar-embed-wrap {
  padding: 0;
  line-height: 0;
}

.avatar-embed-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: block;
}

/* --- Section header / toggle button --- */
.avatar-section-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(108,92,231,0.04);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.avatar-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}

.avatar-beta-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  margin-right: 4px;
}

/* --- Setup card --- */
.avatar-setup-card {
  padding: 24px 20px 20px;
}

.avatar-setup-intro {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.55;
}

/* --- Three-step grid --- */
.avatar-setup-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.avatar-setup-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.avatar-step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.avatar-step-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avatar-step-body strong {
  font-size: 0.9rem;
  color: var(--text);
}

.avatar-step-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* --- Setup status message --- */
.avatar-setup-status {
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  min-height: 34px;
  transition: all var(--transition);
}

.avatar-setup-status--info {
  background: rgba(108,92,231,0.07);
  color: var(--primary-dark);
  border: 1px solid rgba(108,92,231,0.15);
}

.avatar-setup-status--success {
  background: rgba(0,184,148,0.09);
  color: #086b55;
  border: 1px solid rgba(0,184,148,0.2);
}

.avatar-setup-status--error {
  background: rgba(255,118,117,0.1);
  color: #9b2020;
  border: 1px solid rgba(255,118,117,0.25);
}

.avatar-reset-btn {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.avatar-reset-btn:hover {
  color: var(--danger);
}

/* --- Button size variants --- */
.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  transition: all var(--transition);
  border: none;
}

.btn-sm:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-primary.btn-sm {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-primary.btn-sm:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-secondary.btn-sm {
  background: var(--bg-card);
  color: var(--primary);
  border: 1px solid var(--border-hover);
}

.btn-secondary.btn-sm:hover {
  background: rgba(108,92,231,0.06);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* --- Live avatar panel --- */
.avatar-live-panel {
  flex-direction: column;
  align-items: center;
  padding: 16px 20px 20px;
  gap: 12px;
}

/* --- Video container --- */
.avatar-video-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.avatar-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md);
  transition: opacity 0.6s ease;
}

/* --- Thinking overlay --- */
.avatar-thinking-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.72) 0%, transparent 100%);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.avatar-thinking-text {
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  margin-right: 4px;
}

.avatar-thinking-dot {
  width: 7px;
  height: 7px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: avatar-dot-bounce 1.2s ease-in-out infinite;
}

.avatar-thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.avatar-thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes avatar-dot-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40%           { transform: scale(1.2); opacity: 1; }
}

/* --- Connection badge --- */
.avatar-connection-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(3px);
}

/* --- Stop button (video overlay) --- */
.avatar-stop-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.55) !important;
  border-color: transparent !important;
  color: #fff !important;
  width: 34px !important;
  height: 34px !important;
  backdrop-filter: blur(3px);
}

.avatar-stop-btn:hover {
  background: rgba(220,53,69,0.8) !important;
}

/* --- Mute hint --- */

/* ================================================
   D-ID WebRTC Avatar Video Styles
   ================================================ */

/* --- Video section container --- */
.avatar-video-section {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 24px;
  aspect-ratio: 16 / 9;
  background: linear-gradient(150deg, #1b1530 0%, #14182e 55%, #0f1424 100%);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  /* 3-D tilt driven by JS mouse tracking */
  transform-style: preserve-3d;
  /* Smooth return to neutral when mouse leaves */
  transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1),
              box-shadow 0.4s ease;
  will-change: transform;
}

/* --- Video element (D-ID stream) --- */
.avatar-video-element {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  z-index: 1; /* always above the idle-photo fallback layer */
}

/* --- Idle "life" animation ---
   Applied while the avatar is connected but not speaking, so it always
   feels alive: subtle breathing, gentle sway and periodic micro-blinks.
   While speaking, this class is removed and D-ID drives the real motion. */
.avatar-video-element.idle-life {
  transform-origin: 50% 55%;
  will-change: transform, filter;
  animation: avatarIdleLife 9s ease-in-out infinite;
  backface-visibility: hidden;
}

@keyframes avatarIdleLife {
  /* Natural breathing + gentle sway — values scaled up ~5× vs. old to be visible */
  0%   { transform: translateY(0)      scale(1)      rotate(0deg);     filter: brightness(1); }
  18%  { transform: translateY(-1.8%)  scale(1.009)  rotate(0.45deg);  filter: brightness(1.03); }
  35%  { transform: translateY(-2.4%)  scale(1.012)  rotate(0.6deg);   filter: brightness(1.05); }
  50%  { transform: translateY(0)      scale(1)      rotate(0deg);     filter: brightness(1); }
  68%  { transform: translateY(-1.8%)  scale(1.009)  rotate(-0.45deg); filter: brightness(1.03); }
  82%  { transform: translateY(-2.4%)  scale(1.012)  rotate(-0.6deg);  filter: brightness(1.05); }
  100% { transform: translateY(0)      scale(1)      rotate(0deg);     filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-video-element.idle-life {
    animation: none;
  }
}

/* --- Idle-loop video layer (custom V2 photo avatars) ---
   A silent, D-ID-rendered loop of the user's photo, layered over the live
   stream's frozen frame. We cross-fade between idle and the live talking stream
   so the avatar never appears frozen between utterances. */
.avatar-idle-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease, ease);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* Idle video visible only when a clip is loaded and the avatar is NOT speaking. */
.avatar-video-section.has-idle-video .avatar-idle-video {
  opacity: 1;
}

.avatar-video-section.has-idle-video.speaking .avatar-idle-video {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .avatar-idle-video {
    transition: none;
  }
}

/* --- Idle photo layer (still-image fallback while avatar is not speaking) ---
   Shown when neither the 3-D hologram nor the idle-loop video is available.
   The user's uploaded photo is displayed with the same breathing animation so
   the avatar always feels alive between speaking turns. */
.avatar-idle-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease, ease);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.avatar-video-section.has-idle-photo .avatar-idle-photo {
  opacity: 1;
  animation: avatarIdleLife 9s ease-in-out infinite;
  transform-origin: 50% 55%;
}

.avatar-video-section.has-idle-photo.speaking .avatar-idle-photo {
  opacity: 0;
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .avatar-idle-photo {
    transition: none;
    animation: none !important;
  }
}

/* --- Controls overlay --- */
.avatar-controls-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0.6) 0%,
    transparent 25%,
    transparent 75%,
    rgba(0,0,0,0.7) 100%
  );
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}

/* When connected (active) — show on hover or always-on */
.avatar-video-section:hover .avatar-controls-overlay,
.avatar-controls-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* When NOT connected — always show buttons, no dark gradient */
.avatar-controls-overlay:not(.active) {
  opacity: 1;
  pointer-events: all;
  background: transparent;
}

/* --- Status bar (top) --- */
.avatar-status-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.avatar-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  transition: all 0.3s var(--ease);
}

.avatar-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s ease-in-out infinite;
}

.avatar-status.disconnected {
  background: rgba(108, 117, 125, 0.85);
  color: #e0e0e0;
}

.avatar-status.connecting {
  background: rgba(253, 203, 110, 0.85);
  color: #111;
}

.avatar-status.connecting::before {
  animation: pulse 0.8s ease-in-out infinite;
}

.avatar-status.connected {
  background: rgba(0, 184, 148, 0.85);
  color: #fff;
}

.avatar-status.error {
  background: rgba(255, 118, 117, 0.85);
  color: #fff;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* --- Language selector bar (between status + action buttons) --- */
.avatar-lang-bar {
  display: none; /* moved into settings popup */
}

.avatar-lang-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font);
  padding: 6px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  outline: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.avatar-lang-select:hover {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.avatar-lang-select option {
  background: #1a1a2e;
  color: #fff;
}

.avatar-settings-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 2px 0;
}

.avatar-settings-lang {
  padding: 2px 4px 4px;
}

/* --- Action buttons (bottom center) --- */
.avatar-action-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.btn-avatar-primary,
.btn-avatar-danger,
.btn-avatar-secondary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.3s var(--ease);
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.btn-avatar-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 6px 22px var(--primary-glow), 0 2px 8px rgba(0,0,0,0.28);
}

.btn-avatar-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--primary-glow);
}

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

.btn-avatar-secondary {
  background: linear-gradient(135deg, #74B9FF, #0984E3);
  color: #fff;
}

.btn-avatar-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(116,185,255,0.4);
}

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

.btn-avatar-danger {
  background: linear-gradient(135deg, #FF7675, #D63031);
  color: #fff;
}

.btn-avatar-unmute {
  background: linear-gradient(135deg, #FDCB6E, #E17055);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  animation: pulse-unmute 1.4s ease-in-out infinite;
}

.btn-avatar-unmute:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(225,112,85,0.5);
  animation: none;
}

@keyframes pulse-unmute {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225,112,85,0.5); }
  50%       { box-shadow: 0 0 0 8px rgba(225,112,85,0); }
}

.btn-avatar-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(255,118,117,0.4);
}

/* ── Live mic (continuous conversation) button ── */
.btn-avatar-live {
  background: linear-gradient(135deg, #6C5CE7, #00B894);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-avatar-live:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(108,92,231,0.45);
}

.btn-avatar-live.live-on {
  background: linear-gradient(135deg, #00B894, #00CEC9);
  animation: pulse-live 1.3s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,184,148,0.6); }
  50%       { box-shadow: 0 0 0 10px rgba(0,184,148,0); }
}

/* ── Live caption overlay ── */
.avatar-caption {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  max-width: 86%;
  padding: 10px 18px;
  background: rgba(0,0,0,0.62);
  color: #fff;
  font-size: 1.05rem;
  line-height: 1.5;
  border-radius: 12px;
  text-align: center;
  backdrop-filter: blur(3px);
  z-index: 6;
  pointer-events: none;
  animation: caption-fade 0.25s ease;
}

@keyframes caption-fade {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Listening indicator ── */
.avatar-listening {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(0,184,148,0.85);
  color: #fff;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 6;
}

.avatar-listening .listening-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  display: inline-block;
  animation: listening-bounce 1s ease-in-out infinite;
}

.avatar-listening .listening-dot:nth-child(2) { animation-delay: 0.15s; }
.avatar-listening .listening-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes listening-bounce {
  0%, 100% { transform: scale(0.6); opacity: 0.5; }
  50%       { transform: scale(1);   opacity: 1; }
}

.avatar-listening .listening-label { margin-inline-start: 4px; }

/* Processing state: indicator turns purple while waiting for avatar response */
.avatar-listening.processing {
  background: rgba(108, 92, 231, 0.90);
}

/* ── User speech transcript (shown immediately after speech is recognised) ── */
.avatar-user-transcript {
  position: absolute;
  left: 50%;
  top: 56px; /* just below the listening indicator */
  transform: translateX(-50%);
  max-width: 80%;
  padding: 5px 14px;
  background: rgba(108, 92, 231, 0.80);
  color: #fff;
  font-size: 0.88rem;
  border-radius: 20px;
  text-align: center;
  backdrop-filter: blur(3px);
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: caption-fade 0.2s ease;
}

/* ── Fullscreen layout ── */
.avatar-video-section:fullscreen,
.avatar-video-section:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  background: #000;
}

.avatar-video-section:fullscreen .avatar-video-element,
.avatar-video-section:-webkit-full-screen .avatar-video-element {
  object-fit: contain;
}

.avatar-video-section:fullscreen .avatar-caption,
.avatar-video-section:-webkit-full-screen .avatar-caption {
  font-size: 1.4rem;
  bottom: 8%;
}

/* ── Fullscreen text input panel (shown when not in live-mic mode) ── */
.avatar-fs-input-panel {
  display: none;
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 88vw);
  z-index: 10;
  background: rgba(10, 10, 30, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
  padding: 10px 14px;
  display: none;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.avatar-video-section:fullscreen .avatar-fs-input-panel.visible,
.avatar-video-section:-webkit-full-screen .avatar-fs-input-panel.visible {
  display: flex;
}

/* In fullscreen push the input panel above the button row (~70 px tall + 20 px padding) */
.avatar-video-section:fullscreen .avatar-fs-input-panel,
.avatar-video-section:-webkit-full-screen .avatar-fs-input-panel {
  bottom: 90px;
}

.avatar-fs-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  direction: rtl;
  padding: 4px 8px;
}

.avatar-fs-input::placeholder {
  color: rgba(255,255,255,0.45);
}

.avatar-fs-send-btn {
  flex-shrink: 0;
  background: var(--primary, #7c3aed);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  cursor: pointer;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
}

.avatar-fs-send-btn:hover {
  background: var(--primary-dark, #5b21b6);
}

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

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
  .avatar-video-section {
    max-width: 100%;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
  }

  .avatar-controls-overlay {
    padding: 12px;
  }

  .avatar-action-buttons {
    gap: 12px;
  }

  .btn-avatar-primary,
  .btn-avatar-secondary,
  .btn-avatar-danger {
    padding: 12px 20px;
    font-size: 0.9rem;
  }

  .avatar-status {
    font-size: 0.75rem;
    padding: 5px 12px;
  }
}

/* --- Mute hint (kept from original) --- */
.avatar-mute-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Crisis Safe-Messaging Card ──────────────────────────────────────────── */
.avatar-crisis-card {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(160deg, #0a0015 0%, #1a0030 60%, #0d0020 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  overflow-y: auto;
  animation: crisis-card-in 0.5s var(--ease);
}

@keyframes crisis-card-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.crisis-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  animation: crisis-pulse 2s ease-in-out infinite;
}

@keyframes crisis-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.1); }
}

.crisis-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.crisis-message {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.88);
  text-align: center;
  max-width: 520px;
  line-height: 1.7;
  margin-bottom: 32px;
}

/* --- Hotlines grid --- */
.crisis-hotlines {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  margin-bottom: 28px;
}

.crisis-hotline-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  backdrop-filter: blur(3px);
}

.crisis-hotline-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.crisis-hotline-item strong {
  display: block;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.crisis-hotline-number {
  display: inline-block;
  color: #A29BFE;
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.03em;
  margin-left: 8px;
}

.crisis-hotline-number:hover {
  color: #fff;
  text-decoration: underline;
}

.crisis-hotline-hours {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  margin-right: 8px;
}

/* --- SMS notification note --- */
.crisis-sms-note {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  text-align: center;
  max-width: 420px;
  line-height: 1.55;
  margin-bottom: 28px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
}

/* --- Continue button --- */
.crisis-continue-btn {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-full);
  padding: 10px 24px;
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.crisis-continue-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* --- Responsive adjustments for avatar section --- */
@media (max-width: 640px) {
  .avatar-setup-steps {
    gap: 10px;
  }
  .avatar-video-wrap {
    max-width: 100%;
  }
  .crisis-title {
    font-size: 1.5rem;
  }
  .crisis-message {
    font-size: 0.95rem;
  }
  .crisis-hotline-number {
    font-size: 1.2rem;
  }
}

/* ══════════════════════════════════════════════════════
   HOLOGRAM EFFECT
   ══════════════════════════════════════════════════════ */

/* Live 3-D hologram stage — depth-parallax canvas fills the section */
.avatar-3d-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  display: none;
}
.avatar-3d-stage.active {
  display: block;
  z-index: 3;
}

/* ═══════════════════════════════════════════════════════════════════
   HOLOGRAM 3D EFFECT
   Applied when hologram-active class is present (on by default).
   Layers: outer glow pulse → scanlines → sweep line → edge vignette →
           chromatic aberration filter on video → glitch flicker.
   ═══════════════════════════════════════════════════════════════════ */

/* Hologram overlay — base scanlines */
.hologram-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.6s ease;
  border-radius: inherit;
  /* Fine horizontal scan lines */
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0, 240, 255, 0.025) 3px,
      rgba(0, 240, 255, 0.025) 4px
    );
  animation: hologram-flicker 5s linear infinite;
}

/* Edge vignette — soft cyan glow at perimeter */
.hologram-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    ellipse at center,
    transparent 42%,
    rgba(0, 240, 255, 0.08) 75%,
    rgba(0, 240, 255, 0.22) 100%
  );
  pointer-events: none;
  animation: holo-edge-pulse 4s ease-in-out infinite;
}

/* Sweep line — bright horizontal beam scrolling top → bottom */
.hologram-overlay::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 5px;
  top: -5px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 240, 255, 0.12) 15%,
    rgba(0, 240, 255, 0.75) 50%,
    rgba(0, 240, 255, 0.12) 85%,
    transparent 100%
  );
  box-shadow: 0 0 14px 5px rgba(0, 240, 255, 0.45);
  pointer-events: none;
  animation: holo-scan 3.5s linear infinite;
}

/* Show overlay only in hologram mode */
.avatar-video-section.hologram-active .hologram-overlay {
  opacity: 1;
}

/* ── Video element: cyan tint + chromatic aberration ── */
.avatar-video-section.hologram-active .avatar-video-element {
  filter:
    hue-rotate(185deg)
    saturate(1.65)
    brightness(1.15)
    contrast(1.08)
    drop-shadow(3px  0px 0px rgba(255, 30, 100, 0.45))
    drop-shadow(-3px 0px 0px rgba(0,  240, 255, 0.45));
  transition: filter 0.5s ease;
}

/* ── Outer glow ring — pulses to simulate hologram projection power ── */
.avatar-video-section.hologram-active {
  animation: holo-pulse-glow 4s ease-in-out infinite;
}

/* ── Animations ── */
@keyframes holo-scan {
  0%   { top: -5px; }
  100% { top: 100%; }
}

@keyframes holo-edge-pulse {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1.0; }
}

@keyframes holo-pulse-glow {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(0, 240, 255, 0.55),
      0 0 18px rgba(0, 240, 255, 0.45),
      0 0 55px rgba(0, 240, 255, 0.2),
      var(--shadow-xl);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(0, 240, 255, 0.85),
      0 0 40px rgba(0, 240, 255, 0.7),
      0 0 90px rgba(0, 240, 255, 0.35),
      0 0 160px rgba(0, 240, 255, 0.12),
      var(--shadow-xl);
  }
}

@keyframes hologram-flicker {
  0%, 85%  { opacity: 1; }
  86%      { opacity: 0.55; }
  87%      { opacity: 1; }
  91%      { opacity: 0.35; }
  92%      { opacity: 1; }
  97%      { opacity: 0.75; }
  98%      { opacity: 1; }
  100%     { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .hologram-overlay,
  .hologram-overlay::before,
  .hologram-overlay::after,
  .avatar-video-section.hologram-active {
    animation: none;
  }
}

/* Hologram toggle button in the header */
.hologram-toggle-btn {
  font-size: 0.8rem;
  padding: 4px 12px;
  height: 32px;
  gap: 6px;
  color: var(--text-muted);
  border-color: var(--border);
}
.hologram-toggle-btn.hologram-on {
  color: #00f0ff;
  border-color: rgba(0, 240, 255, 0.5);
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}

/* Avatar photo placeholder (before stream starts) */
.avatar-photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(108,92,231,0.28), transparent 62%),
    linear-gradient(150deg, #211a3d 0%, #181b33 55%, #11152a 100%);
  z-index: 1;
  border-radius: inherit;
  transition: opacity 0.4s ease;
}
body.dark-mode .avatar-photo-placeholder {
  background:
    radial-gradient(circle at 50% 38%, rgba(59,130,196,0.3), transparent 62%),
    linear-gradient(150deg, #0c1726 0%, #0a1422 55%, #07101c 100%);
}

.avatar-photo-placeholder.hidden {
  opacity: 0;
  pointer-events: none;
}

.placeholder-inner {
  text-align: center;
}

.placeholder-icon {
  width: 88px;
  height: 88px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 0 0 10px rgba(255,255,255,0.03), inset 0 1px 8px rgba(255,255,255,0.08);
  opacity: 0.85;
}

.placeholder-text {
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
}
.placeholder-text strong { color: var(--primary-light); }

/* Emotion badge next to avatar status */
.avatar-emotion-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
  color: #fff;
  backdrop-filter: blur(3px);
  transition: all 0.4s ease;
}

/* --- Avatar effects disabled: keep the screen clean/static --- */
.avatar-video-section {
  transform: none !important;
  transition: none !important;
  box-shadow: var(--shadow-lg);
}

.avatar-video-element.idle-life,
.avatar-video-section.has-idle-photo .avatar-idle-photo {
  animation: none !important;
  transform: none !important;
  filter: none !important;
}

.avatar-status::before,
.btn-avatar-unmute,
.btn-avatar-live.live-on,
.avatar-listening .listening-dot,
.hologram-overlay,
.avatar-3d-stage,
.hologram-toggle-btn {
  animation: none !important;
}

.hologram-overlay,
.avatar-3d-stage,
.hologram-toggle-btn {
  display: none !important;
}

/* ══════════════════════════════════════════════════════
   AVATAR SETUP MODAL
   ══════════════════════════════════════════════════════ */

.avatar-setup-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.avatar-setup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
}

.avatar-setup-panel {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 40px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl), 0 0 80px rgba(108,92,231,0.2);
  animation: modal-slide-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-slide-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.avatar-setup-header {
  text-align: center;
  margin-bottom: 28px;
  position: relative;
}

.avatar-setup-logo {
  font-size: 2.8rem;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.avatar-setup-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.avatar-setup-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto;
}

.avatar-setup-close {
  position: absolute;
  top: 0;
  left: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.avatar-setup-close:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-light);
}

/* Steps indicator */
.avatar-setup-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
}

.setup-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s ease;
}

.setup-step.active .step-dot {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 16px var(--primary-glow);
}

.setup-step.done .step-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.step-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.setup-step.active .step-label {
  color: var(--primary);
  font-weight: 700;
}

.step-connector {
  height: 2px;
  width: 60px;
  background: var(--border);
  margin: 0 4px;
  margin-bottom: 22px;
  transition: background 0.4s ease;
}

.step-connector.done {
  background: var(--success);
}

/* Setup step content */
.setup-step-content {
  animation: step-fade-in 0.3s ease;
}

@keyframes step-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Drop zone */
.photo-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg);
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.photo-drop-zone:hover,
.photo-drop-zone.drag-over {
  border-color: var(--primary-light);
  background: rgba(108, 92, 231, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.drop-zone-content {
  pointer-events: none;
}

.drop-zone-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.drop-zone-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.drop-zone-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.drop-zone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Photo preview inside drop zone */
.photo-preview-wrap {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.photo-preview-img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--primary-light);
  box-shadow: 0 0 0 6px rgba(108, 92, 231, 0.1), 0 8px 24px var(--primary-glow);
}

.photo-preview-badge {
  background: rgba(0, 184, 148, 0.1);
  color: var(--success);
  border: 1px solid rgba(0, 184, 148, 0.25);
  border-radius: var(--radius-full);
  padding: 4px 16px;
  font-size: 0.82rem;
  font-weight: 600;
}

.change-photo-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.change-photo-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

/* Tips */
.photo-tips {
  background: rgba(108, 92, 231, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.tips-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tips-list li {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding-right: 16px;
  position: relative;
}

.tips-list li::before {
  content: '✓';
  position: absolute;
  right: 0;
  color: var(--success);
  font-weight: 700;
}

/* Create avatar button */
.btn-create-avatar {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 24px var(--primary-glow);
  letter-spacing: 0.01em;
}
.btn-create-avatar:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px var(--primary-glow);
}
.btn-create-avatar:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Replica selection grid ── */
.replica-selection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 4px;
}

.replica-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  text-align: center;
  user-select: none;
}

.replica-card:hover {
  border-color: var(--primary, #7c6af7);
  background: rgba(124, 106, 247, 0.1);
  transform: translateY(-2px);
}

.replica-card.selected,
.replica-card[aria-checked="true"] {
  border-color: var(--primary, #7c6af7);
  background: rgba(124, 106, 247, 0.18);
  box-shadow: 0 0 0 3px rgba(124, 106, 247, 0.25);
}

.replica-card-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.replica-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #fff);
}

.replica-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted, rgba(255,255,255,0.55));
}

/* Thumbnail wrapper for personal/account avatars */
.replica-card-thumb {
  font-size: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.replica-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Source-type badges */
.replica-card-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.replica-card-badge--personal {
  background: rgba(124, 106, 247, 0.25);
  color: #b8aaff;
}
.replica-card-badge--account {
  background: rgba(247, 180, 50, 0.2);
  color: #f7c853;
}
.replica-card-badge--training {
  background: rgba(255, 165, 0, 0.2);
  color: #ffa040;
  animation: pulse-badge 1.4s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* Delete (×) button on personal avatar cards */
.replica-card-delete {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 80, 80, 0.7);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.replica-card:hover .replica-card-delete,
.replica-card.selected .replica-card-delete {
  display: flex;
}
/* Cards with a delete button need relative positioning */
.replica-card:has(.replica-card-delete) {
  position: relative;
}

/* ── Avatar Library Modal ── */
.avatar-library-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.avatar-library-panel {
  background: #161626;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  width: min(960px, 96vw);
  /* KEY: explicit height so flex grid can fill+scroll */
  height: min(660px, 88vh);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 28px 72px rgba(0,0,0,0.7);
}
.avatar-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.avatar-library-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text, #fff);
}
.avatar-library-grid {
  overflow-y: auto;
  flex: 1 1 0;        /* fill remaining height after header */
  min-height: 0;      /* allow shrinking below content size */
  padding: 20px 24px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px;
  align-content: start;
}
/* Scroll styling */
.avatar-library-grid::-webkit-scrollbar { width: 6px; }
.avatar-library-grid::-webkit-scrollbar-track { background: transparent; }
.avatar-library-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
/* ── Section dividers ── */
.avatar-lib-section-header {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 4px 2px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 4px;
}
.avatar-lib-section-header:not(:first-child) { margin-top: 16px; }
/* Responsive */
@media (max-width: 700px) {
  .avatar-library-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    padding: 14px 16px;
  }
}
@media (max-width: 480px) {
  .avatar-library-panel { border-radius: 16px; height: min(560px, 92vh); }
  .avatar-library-grid  { grid-template-columns: repeat(2, 1fr); padding: 12px; }
}

/* ── Avatar library cards ── */
.avatar-lib-card {
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.15s;
  /* Perf: each card is independent paint unit */
  contain: layout style paint;
}
.avatar-lib-card:hover {
  border-color: rgba(124,106,247,0.5);
  background: rgba(124,106,247,0.08);
  transform: translateY(-2px);
}
.avatar-lib-card.is-default {
  border-color: var(--primary, #7c6af7);
  background: rgba(124, 106, 247, 0.13);
}
.avatar-lib-thumb {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.08);
}
.avatar-lib-card.is-default .avatar-lib-thumb {
  border-color: rgba(124,106,247,0.6);
}
.avatar-lib-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Shared preview media (video/img) inside circular thumbs and replica cards */
.av-preview-video,
.av-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.replica-card-thumb {
  overflow: hidden;
}
.replica-card-thumb .av-preview-video,
.replica-card-thumb .av-preview-img {
  border-radius: 50%;
}
.avatar-lib-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text, #fff);
  word-break: break-word;
}
.avatar-lib-badge {
  font-size: 0.67rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.avatar-lib-badge.default  { background: rgba(124,106,247,0.35); color: #c0b4ff; }
.avatar-lib-badge.personal { background: rgba(124,106,247,0.15); color: #a090ff; }
.avatar-lib-badge.account  { background: rgba(247,180,50,0.2);   color: #f7c853; }
.avatar-lib-badge.stock    { background: rgba(255,255,255,0.1);   color: #bbb; }
.avatar-lib-badge.training { background: rgba(255,165,0,0.2);     color: #ffa040;
  animation: pulse-badge 1.4s ease-in-out infinite; }
.avatar-lib-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
}
.avatar-lib-btn {
  font-size: 0.73rem;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  color: var(--text, #fff);
  cursor: pointer;
  transition: background 0.15s;
}
.avatar-lib-btn:hover   { background: rgba(255,255,255,0.1); }
.avatar-lib-btn.danger  { border-color: rgba(255,80,80,0.4); color: #ff9090; }
.avatar-lib-btn.danger:hover { background: rgba(255,80,80,0.15); }
.avatar-lib-loading {
  color: var(--text-muted, rgba(255,255,255,0.5));
  text-align: center;
  padding: 40px 20px;
  grid-column: 1 / -1;
  font-size: 0.9rem;
}

/* ── Voice status box (shown when a voice is already cloned) ── */
.voice-status-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(124, 247, 124, 0.08);
  border: 1px solid rgba(124, 247, 124, 0.25);
  margin-bottom: 14px;
}

.voice-status-icon {
  font-size: 1.5rem;
}

.voice-status-info {
  flex: 1;
}

.voice-status-label {
  font-size: 0.75rem;
  color: var(--text-muted, rgba(255,255,255,0.55));
}

.voice-status-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #fff);
}

/* ── Avatar manage buttons ── */
.btn-avatar-manage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary, rgba(255,255,255,0.75));
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-avatar-manage:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* ── Avatar settings hover popup ─────────────────────── */
.avatar-settings-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-settings-trigger {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.avatar-settings-trigger:hover,
.avatar-settings-wrap.open .avatar-settings-trigger {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.35);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.1);
}

/* Popup panel — hidden until .open */
.avatar-settings-popup {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(20,20,30,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 8px;
  min-width: 140px;
  backdrop-filter: blur(4px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(8px) scale(0.95);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  z-index: 50;
  white-space: nowrap;
}
/* Invisible bridge to keep hover active */
.avatar-settings-popup::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 0;
  right: 0;
  height: 12px;
}
.avatar-settings-wrap.open .avatar-settings-popup {
  pointer-events: all;
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.avatar-settings-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.8);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: right;
  direction: rtl;
  transition: background 0.15s, color 0.15s;
}
.avatar-settings-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
/* ── end avatar settings popup ───────────────────────── */

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
}

@media (max-width: 600px) {
  .replica-selection-grid {
    grid-template-columns: 1fr;
  }
}

/* Processing animation */
.processing-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
}

.processing-rings {
  position: absolute;
  inset: 0;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
  animation: spin linear infinite;
}

.ring-1 {
  inset: 0;
  border-top-color: var(--primary);
  animation-duration: 1.2s;
}

.ring-2 {
  inset: 12px;
  border-top-color: var(--accent);
  animation-duration: 1.8s;
  animation-direction: reverse;
}

.ring-3 {
  inset: 24px;
  border-top-color: var(--primary-light);
  animation-duration: 2.4s;
}

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

.processing-icon {
  position: relative;
  font-size: 2.2rem;
  z-index: 1;
}

.processing-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.processing-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Ready step */
.ready-animation {
  text-align: center;
  margin-bottom: 20px;
}

.ready-checkmark {
  font-size: 4rem;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.ready-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.ready-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
}

/* Responsive modal */
@media (max-width: 600px) {
  .avatar-setup-panel {
    padding: 24px 20px;
    border-radius: var(--radius-lg);
  }
  .avatar-setup-title {
    font-size: 1.25rem;
  }
  .step-connector {
    width: 32px;
  }
}

/* --- Control Panel (לוח בקרה) --- */
.dashboard-intro {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  backdrop-filter: blur(3px);
}
.dashboard-intro p { margin: 0; }

.panel-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.panel-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.settings-section {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 8px 0 0;
}

.incident-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}

.incident-grid label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.incident-grid select,
.incident-grid input[type="range"] {
  width: 100%;
}

.incident-grid select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
}

.incident-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* === Dashboard link button (home header) === */
.dashboard-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: rgba(108,92,231,0.08);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid var(--border);
  box-shadow: none;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.dashboard-link-btn:hover,
.dashboard-link-btn:focus {
  transform: translateY(-1px);
  background: rgba(108,92,231,0.14);
  border-color: var(--border-hover);
  color: var(--primary-dark);
  outline: none;
}
.dashboard-link-btn svg { stroke: currentColor; }
.dashboard-link-label { white-space: nowrap; }
body.dark-mode .dashboard-link-btn {
  background: rgba(59,130,196,0.12);
  color: var(--primary-light);
}
body.dark-mode .dashboard-link-btn:hover,
body.dark-mode .dashboard-link-btn:focus {
  background: rgba(59,130,196,0.2);
  color: #fff;
}
@media (max-width: 520px) {
  .dashboard-link-label { display: none; }
  .dashboard-link-btn { padding: 8px; border-radius: 50%; }
}


/* ===================================================
   Two-column full-height layout (overflow:hidden body)
   =================================================== */

/* Lock the page — no scroll, full viewport */
html, body {
  height: 100%;
  overflow: hidden;
}

/* App shell: vertical flex that fills viewport */
body {
  display: flex;
  flex-direction: column;
}

/* Header: fixed intrinsic height */
.app-header {
  flex-shrink: 0;
}

/* Main: grows to fill all remaining height */
.app-main {
  flex: 1 1 0;
  min-height: 0;
  overflow: visible; /* radial menu needs to overflow; height controlled by flex children */
}

/* Dashboard layout (no two-column chat): allow vertical scrolling, since the
   global `html, body { overflow: hidden }` is meant only for the chat page. */
.app-main:has(.dash-wrap) {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  scroll-behavior: smooth;
}
.app-main:has(.dash-wrap)::-webkit-scrollbar {
  width: 8px;
}
.app-main:has(.dash-wrap)::-webkit-scrollbar-track {
  background: transparent;
}
.app-main:has(.dash-wrap)::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.app-main:has(.dash-wrap)::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
  background-clip: content-box;
}

/* When two-column layout is active: full width, no max-width cap */
.app-main:has(.main-columns) {
  max-width: 100%;
  padding: 20px 32px 20px 32px;
  display: flex;
  flex-direction: column;
}

/* Column wrapper: fills app-main height */
.main-columns {
  display: flex;
  flex-direction: row;
  gap: 28px;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  align-items: stretch;
}

/* Avatar: slightly wider than chat (55/45 split) */
.col-avatar {
  flex: 55 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.col-chat {
  flex: 45 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Avatar column: avatar section fills full column height */
.col-avatar .avatar-section {
  flex: 1 1 0;
  min-height: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.col-avatar .avatar-video-section {
  flex: 1 1 0;
  min-height: 0;
  max-width: 100%;
  margin-bottom: 0;
  border-radius: 0; /* parent section already has radius */
  aspect-ratio: unset;
}

/* In the column layout the video fills the panel — use cover so the avatar
   always fills the display without black bars, cropping only the edges. */
.col-avatar .avatar-video-element,
.col-avatar .avatar-idle-video,
.col-avatar .avatar-idle-photo {
  object-fit: cover;
}

/* Chat column: chat grows, input stays at bottom */
.col-chat .persona-bar {
  flex-shrink: 0;
  padding: 0 2px 8px;
}

.col-chat .chat-container {
  flex: 1 1 0;
  min-height: 0;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.col-chat .chat-container #chat {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  height: 100%;
  border-radius: var(--radius-lg); /* match container */
}

.col-chat .input-area {
  flex-shrink: 0;
  margin-bottom: 0;
  position: relative;
  z-index: 200;
  overflow: visible;
}

/* Footer: hide in full-height mode to save space */
.app-footer {
  display: none;
}

/* Mobile tab bar: hidden on desktop */
.mobile-tab-bar {
  display: none;
}

/* ── Mobile: tab-based navigation (<= 900px) ── */
@media (max-width: 900px) {
  /* Show tab bar */
  .mobile-tab-bar {
    display: flex;
    flex-shrink: 0;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    direction: rtl;
  }

  .mobile-tab {
    flex: 1;
    padding: 13px 8px;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    margin-bottom: -2px; /* overlap the container border */
  }

  .mobile-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(108, 92, 231, 0.06);
    font-weight: 600;
  }

  /* Remove padding on main — content fills edge-to-edge */
  .app-main:has(.main-columns) {
    padding: 0;
  }

  /* Stack columns; gap removed */
  .main-columns {
    flex-direction: column;
    gap: 0;
  }

  /* Each column fills all remaining height */
  .col-avatar,
  .col-chat {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
  }

  /* Avatar video: unset ratio so it fills height */
  .col-avatar .avatar-video-section {
    aspect-ratio: unset;
    border-radius: 0;
  }

  /* Chat: no cap — flex controls height */
  .col-chat .chat-container #chat {
    max-height: none;
  }

  /* Hide avatar column when chat tab is active (default) */
  .main-columns:not([data-active-tab]) .col-avatar,
  .main-columns[data-active-tab="chat"] .col-avatar {
    display: none;
  }

  /* Hide chat column when avatar tab is active */
  .main-columns[data-active-tab="avatar"] .col-chat {
    display: none;
  }
}

/* ================================================
   Distress Monitoring & Tracking — 2026 redesign
   ================================================ */

/* --- Distress status strip (header) --- */
.distress-strip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1.5px solid;
  transition: all 0.5s var(--ease);
  white-space: nowrap;
  cursor: default;
}
.distress-strip .ds-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.distress-strip.calm       { color: var(--d-calm);       border-color: var(--d-calm);       background: var(--d-calm-bg); }
.distress-strip.concerned  { color: var(--d-distressed); border-color: var(--d-distressed); background: var(--d-distressed-bg); }
.distress-strip.distressed { color: var(--d-distressed); border-color: var(--d-distressed); background: var(--d-distressed-bg); }
.distress-strip.critical   { color: var(--d-critical);   border-color: var(--d-critical);   background: var(--d-critical-bg); }
.distress-strip.critical .ds-dot { animation: dsPulse 1.4s ease-in-out infinite; }
@keyframes dsPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.5); }
}

/* ================================================
   Floating Action Button (FAB) + radial menu
   ================================================ */
.luma-fab-wrap {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 20px;
  z-index: 500;
}
.luma-fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.25s var(--ease);
  backdrop-filter: blur(4px);
}
.luma-fab:hover {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 6px 22px var(--primary-glow);
  transform: scale(1.06);
}
.luma-fab svg { transition: transform 0.3s var(--ease); }
.luma-fab-wrap.open .luma-fab svg { transform: rotate(45deg); }

/* Menu items pop up above the FAB */
.luma-fab-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  inset-inline-start: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom var(--inline-start, left);
  transition: all 0.22s var(--ease);
}
.luma-fab-wrap.open .luma-fab-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.luma-fab-item {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px 8px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s var(--ease);
  backdrop-filter: blur(4px);
}
.luma-fab-item:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateX(calc(4px * var(--rtl-dir, -1)));
}
.luma-fab-item .fab-emoji {
  font-size: 1.1rem;
  line-height: 1;
}

/* ================================================
   Quick-log incident modal (2-click)
   ================================================ */
.qmodal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.28);
  backdrop-filter: blur(3px);
  z-index: 600;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 20px;
  animation: qfade 0.2s var(--ease);
}
@keyframes qfade { from { opacity: 0; } to { opacity: 1; } }
.qmodal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  width: 300px;
  max-width: calc(100vw - 40px);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(6px);
  animation: qpop 0.24s var(--ease);
}
@keyframes qpop {
  from { transform: translateY(16px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.qmodal-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.qmodal-label {
  display: block;
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 5px;
}
.qmodal-select {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.86rem;
  cursor: pointer;
}
.qmodal-select:focus { border-color: var(--primary); outline: none; }
.qmodal-intensity-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.qmodal-intensity-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.qmodal-intensity-limit { font-size: 0.7rem; color: var(--text-muted); }
.qmodal-slider {
  width: 100%;
  accent-color: var(--primary);
  margin-bottom: 16px;
  cursor: pointer;
}
.qmodal-actions { display: flex; gap: 8px; }
.qmodal-save {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.qmodal-save:hover { box-shadow: 0 4px 16px var(--primary-glow); transform: translateY(-1px); }
.qmodal-cancel {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.86rem;
  cursor: pointer;
}
.qmodal-feedback {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--d-calm);
  font-weight: 600;
  text-align: center;
  min-height: 18px;
}

/* Quick-log modal — type buttons + range + notes (index.html variant) */
.qmodal { position: relative; }
.qmodal-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}
.qmodal-close:hover { background: var(--danger-light); color: var(--danger); }
.qmodal-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -8px 0 16px;
  line-height: 1.5;
}
.qmodal-types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 16px;
}
.qmodal-type {
  padding: 9px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.qmodal-type:hover { border-color: var(--primary); }
.qmodal-type.active {
  border-color: var(--primary);
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 600;
}
.qmodal-range {
  width: 100%;
  accent-color: var(--primary);
  margin: 4px 0 2px;
  cursor: pointer;
}
.qmodal-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.qmodal-notes {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  margin-bottom: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.84rem;
  resize: vertical;
}
.qmodal-notes:focus { border-color: var(--primary); outline: none; }
.qmodal-actions .btn-primary,
.qmodal-actions .btn-ghost { flex: 1; }
.qmodal-status {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--d-calm);
  font-weight: 600;
  text-align: center;
  min-height: 18px;
}

/* ================================================
   Dashboard — card layout, KPI, charts
   ================================================ */
.dash-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 940px;
  margin: 0 auto;
  width: 100%;
}
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.dash-toolbar h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

/* KPI cards */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-hover); }
.kpi-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
}
.kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.05;
}
.kpi-sub { font-size: 0.74rem; color: var(--text-muted); }
.kpi-trend { font-size: 0.74rem; font-weight: 600; }
.kpi-trend.good { color: var(--d-calm); }
.kpi-trend.bad  { color: var(--d-distressed); }

/* Chart cards */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.chart-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

/* Range toggle */
.range-toggle {
  display: inline-flex;
  gap: 3px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.range-btn {
  padding: 5px 13px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.range-btn.active {
  background: var(--primary);
  color: #fff;
}

.chart-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

/* Type legend */
.type-legend { display: flex; flex-direction: column; gap: 8px; }
.type-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.type-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.type-legend-count { margin-inline-start: auto; font-weight: 700; color: var(--text); }

/* Incident list */
.incident-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.incident-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.incident-row:last-child { border-bottom: none; }
.incident-type-badge {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary-glow);
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.incident-dots { display: flex; gap: 2px; flex-shrink: 0; }
.incident-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border-hover); }
.incident-dot.filled { background: var(--primary); }
.incident-num { font-size: 0.78rem; color: var(--text); flex-shrink: 0; font-weight: 600; }
.incident-time { color: var(--text-muted); font-size: 0.7rem; margin-inline-start: auto; white-space: nowrap; }
.incident-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 2px 4px;
  border-radius: 5px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.incident-delete:hover { color: var(--danger); }

/* Empty state */
.dash-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.dash-empty-icon { font-size: 2.8rem; margin-bottom: 12px; opacity: 0.7; }
.dash-empty-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.dash-empty-text { font-size: 0.85rem; max-width: 320px; margin: 0 auto 16px; }

/* ================================================
   Vent corner — Scream into the Void + Punching Bag
   ================================================ */
.vent-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: qfade 0.25s var(--ease);
}
.vent-overlay.scream { background: radial-gradient(circle at 50% 40%, #1a1730 0%, #07060f 100%); }
.vent-overlay.punch  { background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); }

.vent-close {
  position: absolute;
  top: 18px;
  inset-inline-end: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.vent-close:hover { background: rgba(255,255,255,0.18); transform: rotate(90deg); }

/* --- Scream into the void --- */
.scream-box {
  width: 100%;
  max-width: 560px;
  text-align: center;
  color: #e8e6f0;
}
.scream-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 6px; }
.scream-sub { font-size: 0.9rem; color: #9b97b0; margin-bottom: 22px; }
.scream-textarea {
  width: 100%;
  min-height: 180px;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1.5px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.7;
  resize: none;
  outline: none;
  transition: all 0.3s var(--ease);
}
.scream-textarea::placeholder { color: rgba(255,255,255,0.35); }
.scream-textarea:focus { border-color: var(--accent); box-shadow: 0 0 30px rgba(94,196,182,0.18); }
.scream-textarea.shattering { transition: all 0.6s ease; opacity: 0; transform: scale(1.08); filter: blur(3px); }
.scream-actions { margin-top: 20px; display: flex; gap: 12px; justify-content: center; }
.scream-release {
  padding: 13px 34px;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, #6C5CE7, #00CEC9);
  color: #fff;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  box-shadow: 0 6px 24px rgba(108,92,231,0.3);
}
.scream-release:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 34px rgba(108,92,231,0.4); }
.scream-release:disabled { opacity: 0.4; cursor: default; }
.scream-luma {
  margin-top: 26px;
  font-size: 1.05rem;
  color: #c9c5e0;
  min-height: 28px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.scream-luma.show { opacity: 1; }

/* Floating particles released on "scream" */
.scream-particle {
  position: fixed;
  pointer-events: none;
  color: #fff;
  font-weight: 600;
  z-index: 710;
  will-change: transform, opacity;
}

/* --- Punching bag --- */
.punch-box { text-align: center; color: #fff; user-select: none; }
.punch-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 14px; }
.punch-targets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px; }
.punch-target {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: #d6d2ea;
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.punch-target.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.punch-bag {
  width: 190px;
  height: 190px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--primary-light), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(108,92,231,0.35);
  transition: transform 0.08s ease;
  position: relative;
}
.punch-bag:active, .punch-bag.hit { transform: scale(0.9) rotate(-3deg); }
.punch-counter { margin-top: 22px; font-size: 1rem; color: #c9c5e0; min-height: 26px; }
.punch-counter b { color: #fff; font-size: 1.3rem; }
.punch-pop {
  position: fixed;
  pointer-events: none;
  font-size: 1.8rem;
  z-index: 710;
  will-change: transform, opacity;
}

@media (max-width: 700px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .chart-row-2 { grid-template-columns: 1fr; }
  .luma-fab-wrap { bottom: 16px; inset-inline-start: 14px; }
}

/* ================================================
   Home screen — 2026 refresh (calmer, less empty,
   harmonized palette, lighter header)
   ================================================ */

/* Tighter, calmer header */
.app-header { padding: 12px 28px; }
.header-right { gap: 12px; }
.header-left { gap: 10px; }

/* Emotion badge: softer, less competing with distress strip */
.emotion-badge {
  background: rgba(108,92,231,0.06);
  border-color: var(--border);
  font-weight: 600;
  padding: 5px 11px;
}
body.dark-mode .emotion-badge { background: rgba(59,130,196,0.1); color: var(--primary-light); }

/* Distress strip → centered floating pill instead of a full-width band */
#distressStrip.distress-strip {
  align-self: center;
  margin: 12px auto 2px;
  padding: 7px 18px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(3px);
}

/* Persona bar — pill chip, more intentional */
.col-chat .persona-bar {
  align-items: center;
  gap: 8px;
  padding: 0 2px 10px;
}
.persona-bar select {
  border-radius: var(--radius-full);
  padding: 7px 16px;
  box-shadow: var(--shadow-sm);
}

/* Warm, subtle texture in the chat surface so it never feels blank */
.col-chat .chat-container #chat {
  background:
    radial-gradient(circle at 100% 0%, rgba(108,92,231,0.05), transparent 42%),
    radial-gradient(circle at 0% 100%, rgba(0,206,201,0.04), transparent 42%),
    var(--bg-chat);
}
body.dark-mode .col-chat .chat-container #chat {
  background:
    radial-gradient(circle at 100% 0%, rgba(59,130,196,0.1), transparent 42%),
    radial-gradient(circle at 0% 100%, rgba(94,196,182,0.06), transparent 42%),
    var(--bg-chat);
}

/* ── Quick-start suggestion chips (fills the empty space, helps the user begin) ── */
.suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 2px 10px;
  flex-shrink: 0;
}
.suggest-chips .sc-label {
  width: 100%;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1px;
}
.suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s var(--ease);
}
.suggest-chip:hover,
.suggest-chip:focus-visible {
  border-color: var(--primary-light);
  color: var(--primary);
  background: rgba(108,92,231,0.06);
  transform: translateY(-1px);
  outline: none;
}
.suggest-chip .sc-emoji { font-size: 0.95rem; }
body.dark-mode .suggest-chip:hover,
body.dark-mode .suggest-chip:focus-visible {
  background: rgba(59,130,196,0.12);
  color: var(--primary-light);
}
/* Hide the chips once the conversation gets going */
.col-chat[data-chatted="1"] .suggest-chips { display: none; }

@media (max-width: 900px) {
  /* On mobile the columns stack & fill height; keep chips compact */
  .suggest-chips { margin: 8px 12px; }
}
