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

:root {
  --bg:         #09090B;
  --surface:    #18181B;
  --surface2:   #27272A;
  --border:     rgba(255,255,255,0.08);
  --purple:     #8B5CF6;
  --purple-dim: rgba(139,92,246,0.15);
  --purple-hi:  #A78BFA;
  --text:       #FAFAFA;
  --muted:      #A1A1AA;
  --faint:      #52525B;
  --bot-bubble: #1C1C27;
  --user-bubble:#5B21B6;
  --radius:     16px;
  --shadow:     0 8px 40px rgba(0,0,0,0.6);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout wrapper ───────────────────────────── */
.chat-wrapper {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-container {
  width: 100%;
  max-width: 780px;
  height: 100%;
  max-height: 880px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* ── Header ───────────────────────────────────── */
.chat-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #0E0E1A 0%, #13131F 100%);
  flex-shrink: 0;
}

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

.noew-logo {
  display: flex;
  align-items: baseline;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  user-select: none;
}
.logo-n   { font-size: 28px; color: #fff; }
.logo-oew { font-size: 28px; color: var(--purple-hi); }
.logo-year {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple-hi);
  background: var(--purple-dim);
  border: 1px solid rgba(139,92,246,0.3);
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
  letter-spacing: 0;
}

.header-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.header-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #22C55E;
  border-radius: 50%;
  animation: statusPulse 2.5s ease-in-out infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Messages area ────────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

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

/* ── Individual messages ──────────────────────── */
.message {
  display: flex;
  gap: 10px;
  animation: msgIn 0.25s ease both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* Avatar */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
}
.bot-avatar {
  background: linear-gradient(135deg, #6D28D9, #DB2777);
  color: white;
}
.bot-avatar svg { width: 17px; height: 17px; }

.user-avatar {
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* Bubbles */
.bubble {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
}

.bot-bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  color: var(--text);
}

.user-bubble {
  background: var(--user-bubble);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  color: #fff;
}

/* Markdown in bot bubbles */
.bot-bubble p         { margin-bottom: 8px; }
.bot-bubble p:last-child { margin-bottom: 0; }
.bot-bubble ul, .bot-bubble ol { margin: 8px 0 8px 18px; }
.bot-bubble li        { margin-bottom: 4px; }
.bot-bubble strong    { color: var(--purple-hi); font-weight: 600; }
.bot-bubble h3, .bot-bubble h4 {
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--purple-hi);
  font-size: 15px;
}
.bot-bubble code {
  background: rgba(255,255,255,0.07);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: monospace;
}
.bot-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}
.bot-bubble a {
  color: var(--purple-hi);
  text-decoration: underline;
}

/* ── Suggestion chips ─────────────────────────── */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 44px;
  animation: msgIn 0.3s 0.1s ease both;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.chip:hover {
  background: var(--purple-dim);
  border-color: rgba(139,92,246,0.4);
  color: var(--purple-hi);
}

/* ── Typing indicator ─────────────────────────── */
.typing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 10px;
}
.typing-bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.typing-bubble span {
  width: 7px;
  height: 7px;
  background: var(--faint);
  border-radius: 50%;
  animation: dot 1.3s ease-in-out infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-7px); opacity: 1; }
}

/* ── Input area ───────────────────────────────── */
.input-area {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  transition: border-color 0.2s;
}
.input-row:focus-within {
  border-color: rgba(139,92,246,0.5);
}

textarea#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 110px;
  overflow-y: auto;
}
textarea#input::placeholder { color: var(--faint); }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--purple);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s ease;
}
.send-btn:hover    { background: var(--purple-hi); transform: scale(1.05); }
.send-btn:active   { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.send-btn svg      { width: 17px; height: 17px; }

.input-footer {
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  margin-top: 10px;
}
.input-footer a {
  color: var(--faint);
  text-decoration: none;
}
.input-footer a:hover { color: var(--muted); }

/* ── Error state ──────────────────────────────── */
.error-bubble {
  border-color: rgba(239,68,68,0.3) !important;
  color: #FCA5A5 !important;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 600px) {
  .chat-wrapper    { padding: 0; }
  .chat-container  { max-width: 100%; border-radius: 0; max-height: 100vh; height: 100vh; }
  .messages-area   { padding: 16px; }
  .bubble          { max-width: 85%; }
  .input-area      { padding: 10px 14px 14px; }
  .chips-row       { padding-left: 0; }
}

/* ── Standalone page extra ────────────────────── */
@media (min-height: 900px) {
  .chat-container { max-height: 920px; }
}
