* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f1ec;
  display: flex;
  justify-content: center;
  position: fixed; /* stop iOS Safari from scrolling the page itself when the keyboard opens */
  inset: 0;
}

.chat-shell {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh; /* fallback for browsers without JS / visualViewport support */
  height: var(--app-height, 100dvh); /* set by chat.js from window.visualViewport, keyboard-aware */
  background: #ffffff;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0,0,0,0.08);
  overflow: hidden;
}

.chat-header {
  background: #8c1f28;
  color: #fff;
  padding: 18px 20px;
  flex-shrink: 0;
}

.chat-header-logo {
  height: 30px;
  width: auto;
  display: block;
  margin-bottom: 10px;
  background: #fff;
  padding: 4px 8px;
  border-radius: 6px;
}

.chat-header-title { font-size: 18px; font-weight: 700; }
.chat-header-subtitle { font-size: 13px; opacity: 0.85; margin-top: 2px; }

.messages {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.4;
  font-size: 14.5px;
  white-space: pre-wrap;
}

.bubble.bot {
  align-self: flex-start;
  background: #f0ede7;
  color: #262421;
  border-bottom-left-radius: 4px;
}

.bubble.user {
  align-self: flex-end;
  background: #8c1f28;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.typing { color: #999; font-style: italic; }

.choice-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  width: 100%;
  max-width: 90%;
}

.choice-btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #8c1f28;
  background: #fff;
  color: #8c1f28;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.choice-btn:hover { background: #8c1f28; color: #fff; }

.whatsapp-btn {
  align-self: flex-start;
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: #25d366;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.curriculum-btn {
  align-self: flex-start;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid #8c1f28;
  background: #fff;
  color: #8c1f28;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.curriculum-btn:hover { background: #8c1f28; color: #fff; }

.branch-picker {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.branch-picker label { font-size: 13px; color: #555; width: 100%; }

.branch-picker select {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 16px;
}

.branch-picker button, .chat-input button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #8c1f28;
  color: #fff;
  cursor: pointer;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.chat-input input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 16px; /* iOS Safari zooms in on focus if an input's font is under 16px */
}

.hidden { display: none !important; }
