:root {
  --bg: #0b0d10;
  --text: #e8e8e6;
  --text-muted: #8a8f98;
  --bubble-ava: #1c1f24;
  --accent: #5eead4;
  --accent-bg: rgba(94, 234, 212, 0.15);
  --error: #f26d6d;
  --max-width: 640px;
  --input-bar-height: 64px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--bg);
}

/* ---- Header ---- */

.header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  flex-shrink: 0;
}

.wordmark {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a4a44;
  transition: background-color 0.3s ease;
}

.status-dot.active {
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(94, 234, 212, 0); }
}

.clear-link {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px;
}

.clear-link:hover {
  color: var(--text);
}

/* ---- Message list ---- */

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  margin: auto;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.bubble-row {
  display: flex;
  width: 100%;
}

.bubble-row.user {
  justify-content: flex-end;
}

.bubble-row.ava {
  justify-content: flex-start;
}

.bubble {
  max-width: 75%;
  padding: 9px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble-row.user .bubble {
  background: var(--accent-bg);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.bubble-row.ava .bubble {
  background: var(--bubble-ava);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble.error {
  border-left: 3px solid var(--error);
}

.retry-pill {
  margin-top: 4px;
  align-self: flex-start;
  background: none;
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  padding: 4px 12px;
  cursor: pointer;
}

.retry-pill:hover {
  background: rgba(242, 109, 109, 0.1);
}

.error-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* Thinking dots */

.thinking-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 2px 0;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out;
}

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

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.thinking-text {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 6px;
}

.jump-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--input-bar-height) + 12px);
  background: var(--bubble-ava);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ---- Input bar ---- */

.input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #1a1d22;
}

.composer-input {
  flex: 1;
  resize: none;
  max-height: 144px;
  overflow-y: auto;
  background: #14171b;
  color: var(--text);
  border: 1px solid #24282e;
  border-radius: 18px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.35;
}

.composer-input:focus {
  outline: none;
  border-color: #33383f;
}

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

.send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #06110e;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.send-btn:disabled {
  background: #2a2e33;
  color: var(--text-muted);
  cursor: default;
}
