:root {
  --bg-main: #050510;
  --bg-elevated: #111127;
  --bg-elevated-soft: rgba(17, 17, 39, 0.9);
  --accent: #ff5fd1;
  --accent-soft: rgba(255, 95, 209, 0.16);
  --accent-strong: #ff8be3;
  --text-main: #f5f5ff;
  --text-muted: #9a9abf;
  --border-subtle: rgba(255, 255, 255, 0.06);
}

/* базовое */

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: radial-gradient(circle at top, #101026 0, #050510 55%, #02020a 100%);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* страница не скроллится, только messages */
}

/* ====== LANDING (/index.html) ====== */

.landing-root {
  box-sizing: border-box;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 32px;
}

.landing-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
}

.landing-header p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.landing-main {
  margin-top: 20px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
}

/* ====== WEBAPP (/webapp.html) ====== */

.app-root {
  box-sizing: border-box;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  overflow: hidden; /* скролл только внутри messages */
}

/* шапка */

.app-header {
  padding: 8px 10px 6px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(51, 32, 88, 0.95), rgba(10, 8, 40, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

.app-title {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.app-subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

/* контейнер чата */

.chat-container {
  margin-top: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  padding: 10px 8px 8px;
  background: radial-gradient(circle at top, #181632 0, #070818 55%, #03030d 100%);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.8);
  box-sizing: border-box;
  min-height: 0; /* чтобы flex-дети не раздували страницу */
}

/* список сообщений */

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  max-height: 100%;
}

/* строки и пузырьки */

.message-row {
  display: flex;
  width: 100%;
  font-size: 14px;
}

.message-row.bot {
  justify-content: flex-start;
}

.message-row.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 80%;
  padding: 8px 11px;
  border-radius: 16px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
}

.message-row.bot .message-bubble {
  background: var(--bg-elevated-soft);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, var(--accent) 0, var(--accent-strong) 100%);
  color: #111;
  font-weight: 500;
}

/* инпут */

.chat-input-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input-row input[type="text"] {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 9px 12px;
  font-size: 14px;
  background: rgba(6, 6, 18, 0.98);
  color: var(--text-main);
  outline: none;
  box-sizing: border-box;
}

.chat-input-row input[type="text"]::placeholder {
  color: var(--text-muted);
}

.chat-input-row input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 95, 209, 0.4);
}

/* кнопка отправки */

.chat-input-row button[type="submit"] {
  border: none;
  border-radius: 999px;
  padding: 0 14px;
  min-width: 44px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0, #ffb16b 100%);
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.75);
}

.chat-input-row button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

/* адаптив */

@media (min-width: 768px) {
  .app-root {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .app-header {
    padding: 10px 14px 8px;
  }

  .chat-container {
    margin-top: 12px;
    padding: 12px 10px 10px;
  }
}
