* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden; /* 🔥 IMPORTANT: prevents body scroll lock issues */
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";

  background: #ffffff;
  color: #111827;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =========================
   MAIN APP LAYOUT
========================= */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh; /* 🔥 FIX FOR MOBILE VIEWPORT */
  overflow: hidden;
}

/* =========================
   SIDEBAR
========================= */
.sidebar {
  width: 260px;
  background: #f7f7f8;
  border-right: 1px solid #e5e7eb;
  padding: 12px;
  flex-shrink: 0;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #111827;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.new-chat {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #111827;
  color: white;
  cursor: pointer;
  font-family: inherit;
}

/* =========================
   CHAT AREA
========================= */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

/* =========================
   HERO
========================= */
.hero {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 100%;
  max-width: 700px;
  padding: 0 16px;
}

.hero h1 {
  font-size: 34px;
  margin-bottom: 20px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.suggestions button {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: white;
  cursor: pointer;
  font-family: inherit;
}

.suggestions button:hover {
  background: #f3f4f6;
}

/* =========================
   MESSAGES (🔥 FIXED SCROLL)
========================= */
#messages {
  flex: 1;
  min-height: 0; /* 🔥 CRITICAL FIX */
  overflow-y: auto;

  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;

  -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
  overscroll-behavior: contain;
}

/* =========================
   MESSAGE BUBBLES
========================= */
.message {
  max-width: 750px;
  padding: 14px;
  border-radius: 12px;
  line-height: 1.5;
  word-wrap: break-word;

  opacity: 0;
  transform: translateY(10px);
  animation: messageIn 0.25s ease forwards;
}

@keyframes messageIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user {
  align-self: flex-end;
  background: #111827;
  color: white;
}

.bot {
  align-self: flex-start;
  background: #f3f4f6;
}

/* =========================
   INPUT AREA
========================= */
.input-area {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid #e5e7eb;
  background: white;
}

textarea {
  flex: 1;
  resize: none;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  font-family: inherit;
  outline: none;
  font-size: 16px; /* 🔥 prevents zoom on iOS */
}

#sendBtn {
  width: 90px;
  background: #111827;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}

/* =========================
   MOBILE FIXES
========================= */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }

  .new-chat {
    width: auto;
    padding: 8px 12px;
  }

  .hero h1 {
    font-size: 26px;
  }

  #messages {
    padding: 14px;
  }

  .input-area {
    padding: 10px;
  }

  #sendBtn {
    width: 70px;
  }
}

@media (max-width: 420px) {
  .hero h1 {
    font-size: 22px;
  }

  .suggestions button {
    padding: 8px 10px;
    font-size: 13px;
  }

  .message {
    padding: 12px;
  }
}