:root {
  --bg:       #080d14;
  --surface:  #0e1621;
  --card:     #121d2e;
  --border:   #1e2f47;
  --accent:   #00d4ff;
  --accent2:  #f0b429;
  --green:    #00e676;
  --red:      #ff5252;
  --text:     #e2eaf4;
  --muted:    #5a7a99;
  --user-bubble: #0f2a45;
  --bot-bubble:  #0e1e30;
  --glow:     0 0 24px rgba(0,212,255,0.18);
  --app-height: 100%;
}

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

html {
  overscroll-behavior: none;
}

html, body {
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  height: var(--app-height);
  margin: 0;
}

body {
  background: var(--bg);
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-height);
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.bot-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #001f3f 0%, #003366 100%);
  border: 1.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--glow);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.bot-avatar::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(transparent 60%, rgba(0,212,255,0.15) 100%);
  animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bot-info { flex: 1; min-width: 0; }
.bot-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.bot-name span { color: var(--accent); }

.status-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.8); }
}
.status-text {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--green);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  flex-shrink: 0;
}
.clear-btn:hover { border-color: var(--accent); color: var(--accent); }
#chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.suggested-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 6px 0 8px 0;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.suggested-strip::-webkit-scrollbar { display: none; }
.suggested-strip .chip {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  white-space: nowrap;
}
.suggested-strip .chip:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,212,255,0.06); }

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: msg-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.bot .msg-avatar  { background: var(--card); border: 1px solid var(--border); }
.user .msg-avatar { background: rgba(0,212,255,0.12); border: 1px solid rgba(0,212,255,0.25); }

.bubble {
  max-width: min(75%, 420px);
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.bot .bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.user .bubble {
  background: var(--user-bubble);
  border: 1px solid rgba(0,212,255,0.2);
  border-bottom-right-radius: 5px;
}
.bubble strong { color: var(--accent); font-weight: 600; }
.bubble code {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  background: rgba(0,212,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}
.bubble ul { padding-left: 18px; }
.bubble li { margin: 4px 0; }
.bubble a { color: var(--accent); text-decoration: underline; }

.msg-time {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
}
.msg-wrap { display: flex; flex-direction: column; max-width: min(75%, 420px); }
.user .msg-wrap { align-items: flex-end; }
.bot .msg-wrap  { align-items: flex-start; }

.typing-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 12px 16px;
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: typing 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%,60%,100% { opacity: 0.2; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.input-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  transition: border-color 0.2s;
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.08);
}
#user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  resize: none;
  max-height: 100px;
  line-height: 1.5;
  scrollbar-width: none;
}
#user-input::placeholder { color: var(--muted); }
#user-input::-webkit-scrollbar { display: none; }

#send-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  color: var(--bg);
}
#send-btn:hover { background: #33ddff; transform: scale(1.05); }
#send-btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; transform: none; }
#send-btn svg { width: 16px; height: 16px; }

.input-hint {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 0.04em;
}

#error-toast {
  position: fixed;
  bottom: 90px; left: 50%; transform: translateX(-50%);
  background: rgba(255,82,82,0.12);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-family: 'DM Mono', monospace;
  display: none;
  align-items: center;
  gap: 6px;
  z-index: 200;
  white-space: nowrap;
}
