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

:root {
  --bg:          #0f0f13;
  --bg-surface:  #18181f;
  --bg-hover:    #1e1e28;
  --border:      #2a2a36;
  --text:        #e4e4ec;
  --text-dim:    #8b8b9e;
  --text-faint:  #55556a;
  --accent:      #6C5CE7;
  --accent-soft: rgba(108, 92, 231, 0.12);
  --donna:       #A78BFA;
  --donna-bg:    #1a1628;
  --donna-border:#2d2548;
  --user-bg:     #1c2333;
  --user-border: #263046;
  --green:       #4ade80;
  --red:         #f87171;
  --radius:      12px;
  --radius-sm:   8px;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Layout ───────────────────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
}

#header {
  flex-shrink: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}

#input-bar {
  flex-shrink: 0;
  padding: 12px 20px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

/* ── Header ───────────────────────────────────────────────── */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-sep {
  color: var(--text-faint);
  font-weight: 300;
}

.brand-agent {
  font-weight: 500;
  font-size: 15px;
  color: var(--donna);
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.3s;
}

.status-dot.online  { background: var(--green); box-shadow: 0 0 6px rgba(74, 222, 128, 0.4); }
.status-dot.offline { background: var(--red); }
.status-dot.connecting { background: #fbbf24; animation: pulse 1.2s infinite; }

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

.status-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Messages ─────────────────────────────────────────────── */
#messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-group {
  display: flex;
  gap: 12px;
  padding: 12px 0;
}

.msg-group.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-top: 2px;
}

.msg-group.donna .msg-avatar {
  background: var(--accent-soft);
  border: 1px solid var(--donna-border);
}

.msg-group.user .msg-avatar {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
}

.msg-body {
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-sender {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}

.msg-group.donna .msg-sender { color: var(--donna); }
.msg-group.user  .msg-sender { color: var(--text-dim); text-align: right; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-group.donna .msg-bubble {
  background: var(--donna-bg);
  border: 1px solid var(--donna-border);
  border-top-left-radius: 4px;
}

.msg-group.user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-top-right-radius: 4px;
}

.msg-footer {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

.msg-group.user .msg-footer { text-align: right; }

/* Typing indicator */
.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--donna);
  margin: 0 2px;
  animation: bounce 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* Code blocks inside messages */
.msg-bubble pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  margin: 8px 0;
  line-height: 1.5;
}

.msg-bubble code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.msg-bubble pre code {
  background: none;
  padding: 0;
}

/* Bold, italic, lists */
.msg-bubble strong { font-weight: 600; color: #f0f0f8; }
.msg-bubble em { font-style: italic; color: var(--text-dim); }

/* ── Input ────────────────────────────────────────────────── */
.input-wrap {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

#input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
  padding: 4px 0;
}

#input::placeholder { color: var(--text-faint); }

#send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.1s;
  flex-shrink: 0;
}

#send-btn:hover:not(:disabled) { opacity: 0.85; }
#send-btn:active:not(:disabled) { transform: scale(0.95); }
#send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.input-hint {
  max-width: 780px;
  margin: 6px auto 0;
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
}

kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 10px;
}

/* ── Welcome ──────────────────────────────────────────────── */
.welcome {
  text-align: center;
  padding: 60px 20px 40px;
  max-width: 500px;
  margin: 0 auto;
}

.welcome-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--donna-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
}

.welcome h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.welcome p {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ── Onboarding ───────────────────────────────────────────── */
.onboarding {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}

.onboarding.visible {
  display: flex;
}

.onboard-card {
  max-width: 440px;
  width: 100%;
  padding: 48px 36px;
  text-align: center;
}

.onboard-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--donna-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin: 0 auto 20px;
}

.onboard-card h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.onboard-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 32px;
}

.onboard-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
  text-align: left;
}

.onboard-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.feature-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.onboard-feature strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px;
}

.onboard-feature span {
  font-size: 12px;
  color: var(--text-dim);
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  background: white;
  color: #333;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
  margin-bottom: 16px;
}

.google-btn:hover {
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
}

.google-btn:active {
  transform: scale(0.98);
}

.onboard-error {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 8px;
}

.onboard-fine-print {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ── User info in header ──────────────────────────────────── */
.user-info {
  font-size: 12px;
  color: var(--text-dim);
  margin-right: 8px;
  padding: 3px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ── Preference options (onboarding chat) ─────────────────── */
.pref-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pref-option-btn {
  padding: 8px 16px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.pref-option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pref-option-btn:disabled {
  cursor: default;
}

.pref-option-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pref-option-btn.dimmed {
  opacity: 0.35;
}

.pref-text-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.pref-text-input {
  flex: 1;
  padding: 8px 14px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.pref-text-input:focus {
  border-color: var(--accent);
}

.pref-text-input:disabled {
  opacity: 0.5;
}

.pref-text-submit {
  padding: 8px 18px;
  background: var(--accent);
  border: none;
  border-radius: 20px;
  color: white;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.pref-text-submit:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── File drop overlay ────────────────────────────────────── */
.drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 15, 19, 0.92);
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay.visible {
  display: flex;
}

.drop-content {
  text-align: center;
  padding: 48px;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: var(--accent-soft);
  max-width: 400px;
}

.drop-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.drop-content p {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.drop-hint {
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--text-dim) !important;
  margin-top: 4px;
}

/* ── Attach button ────────────────────────────────────────── */
.attach-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s, background 0.2s;
}

.attach-btn:hover {
  color: var(--text);
  background: var(--bg);
}

/* ── Scrollbar ────────────────────────────────────────────── */
#chat::-webkit-scrollbar { width: 6px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#chat::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  #header { padding: 0 12px; }
  #input-bar { padding: 8px 12px 12px; }
  #messages { padding: 0 12px; }
  .msg-body { max-width: calc(100vw - 80px); }
  .brand-name { font-size: 13px; }
}
