:root {
  --bg: #0f141a;
  --panel: #18222d;
  --incoming: #202d3a;
  --outgoing: #2b5278;
  --text: #ecf1f7;
  --muted: #94a2b3;
  --accent: #3390ec;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  justify-content: center;
  position: relative;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 14, 18, 0.92);
  backdrop-filter: blur(6px);
}

/* display:flex у класса перебивает атрибут [hidden] — без этого оверлей остаётся поверх чата */
.auth-overlay[hidden] {
  display: none !important;
}

.app[hidden] {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 22px 20px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid #314154;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.login-hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.login-field input {
  border: 1px solid #314154;
  border-radius: 10px;
  background: #111923;
  color: var(--text);
  font-size: 16px;
  padding: 12px 12px;
  outline: none;
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-error {
  margin: 0 0 12px;
  font-size: 13px;
  color: #f07178;
}

.login-submit {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
}

.login-submit:active {
  opacity: 0.9;
}

.app {
  width: 100%;
  max-width: 720px;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: radial-gradient(circle at top, #1a2633, #0f141a 45%);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #273445;
  background: rgba(16, 23, 32, 0.86);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.header-text h1 {
  margin: 0;
  font-size: 16px;
}

.header-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #7ad17a;
}

.messages {
  overflow-y: auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.38;
  word-wrap: break-word;
  font-size: 15px;
}

.message.user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--outgoing);
}

.message.bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: var(--incoming);
}

.message a.message-link {
  color: #7ec8ff;
  text-decoration: underline;
  word-break: break-all;
}

.message a.message-link:active {
  opacity: 0.85;
}

.chat-input-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #273445;
  background: rgba(16, 23, 32, 0.95);
}

.chat-input-bar input {
  width: 100%;
  border: 1px solid #314154;
  border-radius: 24px;
  background: #111923;
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
}

.chat-input-bar input:focus {
  border-color: var(--accent);
}

.icon-btn,
.send-btn {
  border: none;
  border-radius: 999px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  font-size: 18px;
}

.icon-btn {
  background: #243548;
}

.icon-btn.recording {
  background: #ce3b3b;
}

.send-btn {
  background: var(--accent);
}

.status {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

@media (max-width: 480px) {
  .message {
    max-width: 92%;
    font-size: 14px;
  }
}
