:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1f252d;
  --border: #303844;
  --text: #edf2f7;
  --text-dim: #9aa5b1;
  --accent: #45c2a5;
  --accent-soft: #17362f;
  --user-bubble: #45c2a5;
  --user-text: #061713;
  --bot-bubble: #252c35;
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 10px 34px 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, Arial, sans-serif;
}

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

.chat {
  width: 100%;
  max-width: 760px;
  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;
}

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

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

.chat__logo {
  position: relative;
  width: 34px;
  height: 28px;
  flex: 0 0 auto;
}

.chat__logo-shape {
  position: absolute;
  width: 27px;
  height: 21px;
  border-radius: 7px 10px 7px 10px;
  transform: skewX(-12deg) rotate(-15deg);
}

.chat__logo-shape--back {
  left: 0;
  bottom: 1px;
  background: #063d70;
}

.chat__logo-shape--front {
  right: 0;
  top: 1px;
  background: linear-gradient(135deg, #12a89e 0%, #61d5d0 100%);
  opacity: 0.92;
}

.chat__titles { min-width: 0; }

.chat__title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.chat__iconbtn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
}

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

.chat__iconbtn:disabled { opacity: 0.35; cursor: not-allowed; }

.chat__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
  max-width: 84%;
}

.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;
  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(255, 107, 107, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.42);
}

.typing { display: inline-flex; gap: 4px; align-items: center; }
.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; }

.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: 10px;
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 1.4;
  font-family: inherit;
  outline: none;
}

.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: 10px;
  background: var(--accent);
  color: var(--user-text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.chat__send:hover { opacity: 0.9; }
.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; }
}
