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

:root {
  --bg: #0f0e11;
  --surface: #1a1820;
  --surface2: #231f2e;
  --border: #2e2a3a;
  --accent: #b98fff;
  --accent2: #7c5cbf;
  --text: #e8e4f0;
  --text-muted: #7a7490;
  --user-bg: #2a1f42;
  --elisa-bg: #1e1c2a;
  --radius: 18px;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ── Header ── */
.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 24, 32, 0.95);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}

.logo h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent);
}

.tagline {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Messages ── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.message {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  animation: fadeUp 0.25s ease;
  margin-bottom: 8px;
}

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

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  font-family: var(--font-serif);
}

.message.elisa .avatar {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: white;
}

.message.user .avatar {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.bubble {
  max-width: 72%;
  padding: 13px 17px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.6;
}

.message.elisa .bubble {
  background: var(--elisa-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.message.user .bubble {
  background: linear-gradient(135deg, #3a2460, #2a1f42);
  border: 1px solid rgba(185, 143, 255, 0.2);
  border-bottom-right-radius: 4px;
  color: var(--text);
}

/* ── Typing indicator ── */
.typing-indicator {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  animation: fadeUp 0.2s ease;
}

.typing-indicator.hidden { display: none; }

.dots {
  background: var(--elisa-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  padding: 14px 20px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: blink 1.2s infinite;
}

.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* ── Input ── */
.input-area {
  border-top: 1px solid var(--border);
  padding: 16px 20px 12px;
  background: var(--surface);
}

.input-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-field {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.input-field::placeholder { color: var(--text-muted); }

.input-field:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(124, 92, 191, 0.15);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.1s;
}

.send-btn:hover { opacity: 0.9; }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
  line-height: 1.4;
}

/* ── Mood indicator ── */
.mood-panel {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.mood-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.mood-bar {
  height: 100%;
  width: 50%;
  background: var(--text-muted);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1), background 0.6s ease;
}

.mood-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  justify-content: flex-end;
}

.mood-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: lowercase;
}

.mood-score {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
  transition: color 0.4s;
}

.mood-score.trend-up {
  color: #22c55e;
}

.mood-score.trend-down {
  color: #ef4444;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .bubble { max-width: 85%; }
  .logo h1 { font-size: 18px; }
  .tagline { display: none; }
}
