:root {
  --bg-chat: #0b141a;
  --bg-header: #202c33;
  --bg-bubble-in: #202c33;
  --bg-bubble-out: #005c4b;
  --bg-composer: #202c33;
  --bg-input: #2a3942;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --divider: #222e35;
  --accent: #00a884;
  --danger: #f15c6d;
  --bubble-radius: 7.5px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #0a0f13; color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14.5px; overflow: hidden;
}
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font-family: inherit; color: inherit; }

.app { height: 100vh; height: 100dvh; background: var(--bg-chat); display: grid; grid-template-rows: 1fr; }

/* Gate */
.gate {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.gate.hidden { display: none; }
.gate-card {
  background: var(--bg-header); border-radius: 12px; padding: 28px 30px;
  width: 380px; max-width: 92vw; text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.gate-card h1 { margin: 0 0 8px; font-size: 22px; }
.gate-sub { color: var(--text-secondary); margin: 0 0 18px; font-size: 14px; line-height: 1.4; }
.gate-card form { display: flex; gap: 8px; }
.gate-card input {
  flex: 1; background: var(--bg-input); border: 1px solid transparent;
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.gate-card input:focus { outline: 0; border-color: var(--accent); }
.gate-card button {
  background: var(--accent); color: #001d18;
  border-radius: 8px; padding: 10px 18px; font-weight: 600; font-size: 14px;
}
.gate-fine { color: var(--text-muted); font-size: 12px; margin-top: 14px; font-style: italic; }

/* Chat */
.chat { display: grid; grid-template-rows: auto 1fr auto; height: 100%; min-height: 0; }
.chat-header {
  background: var(--bg-header); border-bottom: 1px solid var(--divider);
  padding: 10px 16px; display: flex; align-items: center; gap: 12px; min-height: 60px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; color: #fff; font-size: 16px; flex: 0 0 auto;
}
.chat-name { font-weight: 600; font-size: 16px; }
.chat-sub { color: var(--text-secondary); font-size: 13px; }

.messages {
  background: var(--bg-chat);
  padding: 18px 16% 12px; overflow-y: auto; min-height: 0;
}
@media (max-width: 760px) { .messages { padding: 14px 12px 8px; } }

.bubble {
  max-width: 70%; margin: 4px 0; padding: 8px 11px 6px;
  border-radius: var(--bubble-radius); position: relative;
  display: inline-flex; flex-direction: column; word-wrap: break-word;
}
.bubble.in { background: var(--bg-bubble-in); align-self: flex-start; border-top-left-radius: 0; }
.bubble.out { background: var(--bg-bubble-out); align-self: flex-end; border-top-right-radius: 0; }
.messages { display: flex; flex-direction: column; }
.bubble .content { white-space: pre-wrap; line-height: 1.45; }
.bubble .time {
  font-size: 11px; color: var(--text-muted); align-self: flex-end; margin-top: 2px;
}
.typing { display: inline-flex; gap: 3px; padding: 6px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary);
  animation: typing 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }

.composer {
  background: var(--bg-composer); border-top: 1px solid var(--divider);
  padding: 10px 16px; display: flex; align-items: flex-end; gap: 10px;
}
.composer-input {
  flex: 1; background: var(--bg-input); border: 0; border-radius: 8px;
  padding: 9px 12px; font-size: 14.5px; resize: none; max-height: 160px; line-height: 1.4;
}
.composer-input:focus { outline: 0; }
.send-btn {
  background: var(--accent); color: #001d18; border-radius: 50%;
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
}
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
