:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #388bfd66;
  --user-msg: #238636;
  --bot-msg: #1f6feb;
  --radius: 12px;
  --font-sans: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --font-head: 'Unbounded', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
}

.layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

@supports (height: 100dvh) {
  body {
    height: 100dvh;
  }

  .layout {
    height: 100dvh;
  }
}

/* Header */
.header {
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  text-align: center;
}

.logo {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.header h1 {
  margin: 0 0 6px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--text);
}

.tagline {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Chat */
.chat-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overscroll-behavior: contain;
}

.welcome {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.welcome p {
  margin: 0;
}

.msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  max-width: 95%;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
}

.msg.bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
}

.msg-role {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.msg.user .msg-role { color: var(--accent); }
.msg.bot .msg-role { color: var(--bot-msg); }

.msg-content {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-content p:first-child { margin-top: 0; }
.msg-content p:last-child { margin-bottom: 0; }

.msg.loading .msg-content::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--accent);
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

.error-msg {
  background: rgba(248, 81, 73, 0.15);
  border-color: #f85149;
  color: #f85149;
}

/* Form */
.form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.input {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  resize: none;
  transition: border-color 0.2s;
}

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

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.submit {
  flex-shrink: 0;
  height: 44px;
  padding: 0 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--bg);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.submit:hover {
  background: #79b8ff;
}

.submit:active {
  transform: scale(0.98);
}

.submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.submit-icon {
  display: none;
}

@media (max-width: 480px) {
  .submit-text { display: none; }
  .submit-icon { display: inline; }
}

/* Footer */
.footer {
  padding: 12px 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
