:root {
  --bg: #0b141a;
  --panel: #111b21;
  --bar: #202c33;
  --green: #25d366;
  --green-dark: #075e54;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --text: #e9edef;
  --text-dim: #8696a0;
}

* { 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;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

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

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bar);
  border-bottom: 1px solid #0a0f12;
  padding-top: max(10px, env(safe-area-inset-top));
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--green-dark);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  flex: 0 0 auto;
}
.who { flex: 1 1 auto; min-width: 0; }
.name { font-size: 16px; font-weight: 600; line-height: 1.2; }
.status { font-size: 12.5px; color: var(--text-dim); }
.status.typing { color: var(--green); }
.newchat {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 26px; cursor: pointer; line-height: 1; padding: 4px 8px;
  border-radius: 8px;
}
.newchat:hover { background: rgba(255,255,255,.06); color: var(--text); }

/* Messages */
.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-image: linear-gradient(rgba(11,20,26,.92), rgba(11,20,26,.92));
}
.row { display: flex; }
.row.user { justify-content: flex-end; }
.row.bot { justify-content: flex-start; }

.bubble {
  max-width: 78%;
  padding: 7px 10px 8px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.42;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,.2);
}
.row.bot .bubble { background: var(--bubble-in); border-top-left-radius: 2px; }
.row.user .bubble { background: var(--bubble-out); border-top-right-radius: 2px; }
.bubble strong { font-weight: 700; }
.bubble .time {
  display: inline-block;
  font-size: 11px;
  color: var(--text-dim);
  float: right;
  margin: 6px 0 -2px 10px;
}
.row.user .bubble .time { color: rgba(233,237,239,.6); }

/* Typing dots */
.dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.3s infinite both;
}
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.welcome {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin: 12px auto 4px;
  max-width: 80%;
  background: rgba(255,255,255,.04);
  padding: 8px 12px;
  border-radius: 8px;
}

/* Composer */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--bar);
}
.input {
  flex: 1 1 auto;
  resize: none;
  border: none;
  outline: none;
  background: #2a3942;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  padding: 11px 14px;
  border-radius: 22px;
  max-height: 140px;
  font-family: inherit;
}
.input::placeholder { color: var(--text-dim); }
.send {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: #062;
  font-size: 19px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .08s ease;
}
.send:active { transform: scale(.92); }
.send:disabled { opacity: .5; cursor: default; }
