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

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --blue: #185FA5;
  --blue-light: #58a6ff;
  --blue-bubble: #1a3a5c;
  --green: #1D9E75;
  --font: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

body {
  background: var(--bg-primary);
  font-family: var(--font);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 780px;
  height: 100vh;
  max-height: 700px;
  padding: 16px;
}

#chat-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-secondary);
}

/* Header */
#chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.dots { display: flex; gap: 6px; }
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
}
.dot-red    { background: #ff5f57; }
.dot-amber  { background: #ffbd2e; }
.dot-green  { background: #28c840; }

#chat-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 4px;
}

#clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
#clear-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadein 0.2s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot  { align-self: flex-start; align-items: flex-start; }

.label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 5px;
  padding: 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--blue-bubble);
  color: #cce0ff;
  border: 1px solid #2a4a70;
  border-bottom-right-radius: 4px;
}

.msg.bot .bubble {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Inline code */
.bubble code {
  font-family: var(--font);
  font-size: 12.5px;
  background: #0d1117;
  color: var(--green);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Code blocks (highlight.js) */
.bubble pre {
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.bubble pre code {
  background: none;
  color: inherit;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Links */
.bubble a {
  color: var(--blue-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bubble a:hover { color: #a5c8ff; }

/* Hint bar */
#hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

/* Input row */
#input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

#user-input {
  flex: 1;
  padding: 9px 13px;
  font-size: 13.5px;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: none;
  outline: none;
  height: 42px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.5;
}
#user-input::placeholder { color: var(--text-muted); }
#user-input:focus { border-color: var(--blue); }

#send-btn {
  padding: 0 16px;
  height: 42px;
  background: var(--blue);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
#send-btn:hover  { background: #0C447C; }
#send-btn:active { transform: scale(0.97); }
#send-btn:disabled { opacity: 0.4; cursor: default; }

/* Thinking dots */
.thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 2px;
}
.thinking span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  animation: blink 1.2s infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.2s; }
.thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%,80%,100% { opacity: 0.15; transform: scale(0.8); }
  40%          { opacity: 1;    transform: scale(1); }
}

/* Scrollbar for textarea */
#user-input::-webkit-scrollbar { width: 4px; }
#user-input::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
