@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700&display=swap');

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Figtree', sans-serif;
  background: #000;
  color: #ffffff;
  overflow: hidden;
}

#particles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── Layout ── */
.ai-layout {
  position: fixed;
  top: 70px;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
}

.chat-main {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 18px;
}

/* ── Header ── */
.header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: #e3dedc;
  text-shadow: 0 0 6px #e3dedc, 0 0 18px rgba(227,222,220,0.4);
}

.header p {
  margin: 0;
  font-size: 0.88rem;
  color: rgba(227,222,220,0.6);
}

.header p a {
  color: #e3dedc;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(227,222,220,0.35);
}

.header p a:hover {
  text-shadow: 0 0 10px #e3dedc;
}

/* ── Controls ── */
.ai-controls {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#model-selector {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(227,222,220,0.35);
  background: rgba(0,0,0,0.75);
  color: #e3dedc;
  font-family: 'Figtree', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  appearance: none;
}

#model-selector:focus {
  outline: none;
  border-color: #e3dedc;
  box-shadow: 0 0 8px rgba(227,222,220,0.35);
}

/* ── Messages ── */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 10px;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb {
  background: rgba(227,222,220,0.2);
  border-radius: 20px;
}

.message {
  padding: 10px 16px;
  margin: 8px 0;
  border-radius: 14px;
  opacity: 0;
  animation: fadeIn 0.35s forwards;
  max-width: 76%;
  font-size: 0.95rem;
  line-height: 1.55;
}

.message.assistant {
  background: rgba(227,222,220,0.06);
  border: 1px solid rgba(227,222,220,0.15);
  margin-right: auto;
  border-radius: 16px 16px 16px 4px;
}

.message.user {
  background: rgba(227,222,220,0.1);
  border: 1px solid rgba(227,222,220,0.3);
  margin-left: auto;
  border-radius: 16px 16px 4px 16px;
}

.message.loading {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  width: fit-content;
}

/* ── Input ── */
.input-container {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.75);
  border: 1.5px solid rgba(227,222,220,0.3);
  box-shadow: 0 0 14px rgba(227,222,220,0.08);
  padding: 10px 12px;
  border-radius: 11px;
  gap: 8px;
}

.input-container:focus-within {
  border-color: #e3dedc;
  box-shadow: 0 0 18px rgba(227,222,220,0.2);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.95rem;
  font-family: 'Figtree', sans-serif;
  outline: none;
  resize: none;
  min-height: 28px;
  max-height: 140px;
}

textarea::placeholder {
  color: rgba(227,222,220,0.4);
}

.send-btn {
  flex-shrink: 0;
  background: rgba(227,222,220,0.1);
  border: 1.5px solid rgba(227,222,220,0.4);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s, transform 0.2s;
}

.send-btn:hover {
  background: rgba(227,222,220,0.18);
  box-shadow: 0 0 12px rgba(227,222,220,0.4);
  transform: scale(1.06);
}

.send-btn svg {
  width: 18px;
  height: 18px;
  fill: #e3dedc;
}

/* ── Spinner ── */
.spinner {
  border: 3px solid rgba(227,222,220,0.15);
  border-top: 3px solid #e3dedc;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 1s linear infinite;
  margin-right: 8px;
  flex-shrink: 0;
}

/* ── Markdown ── */
.message pre {
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(227,222,220,0.15);
  color: #e3dedc;
  padding: 10px 12px;
  border-radius: 7px;
  overflow-x: auto;
  white-space: pre-wrap;
  font-size: 0.88rem;
}

.message code {
  background: rgba(227,222,220,0.08);
  border: 1px solid rgba(227,222,220,0.15);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
}

.message a {
  color: #e3dedc;
  text-decoration: none;
  border-bottom: 1px solid rgba(227,222,220,0.4);
}

.message a:hover {
  text-shadow: 0 0 8px #e3dedc;
}

/* ── Keyframes ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .chat-main { padding: 10px 12px 14px; }
  .message { max-width: 94%; }
  .header h1 { font-size: 1.4rem; }
}