:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c222b;
  --border: #2a313c;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #e8833a;
  --accent-soft: #3a2a1c;
  --user-bubble: #e8833a;
  --user-text: #1a1206;
  --bot-bubble: #21262d;
  --danger: #f85149;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.chat {
  width: 100%;
  max-width: 720px;
  height: min(880px, 94vh);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}

.chat__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex: 0 0 auto;
}

.chat__titles { min-width: 0; }

.chat__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.chat__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat__session {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.chat__iconbtn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.05s;
}

.chat__iconbtn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chat__iconbtn:active:not(:disabled) { transform: scale(0.94); }
.chat__iconbtn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Messages */
.chat__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat__messages::-webkit-scrollbar { width: 10px; }
.chat__messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

.msg {
  display: flex;
  max-width: 84%;
  animation: fade-in 0.18s ease-out;
}

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

.msg__bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg--user .msg__bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.msg--bot .msg__bubble {
  background: var(--bot-bubble);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg--error .msg__bubble {
  background: rgba(248, 81, 73, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.4);
}

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

/* Input */
.chat__inputbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}

.chat__input {
  flex: 1 1 auto;
  resize: none;
  max-height: 140px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 1.4;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.chat__input:focus { border-color: var(--accent); }
.chat__input::placeholder { color: var(--text-dim); }

.chat__send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #1a1206;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}

.chat__send:hover { opacity: 0.9; }
.chat__send:active { transform: scale(0.94); }
.chat__send:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

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