/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}

:root {
  --blue:   #4285f4;
  --red:    #ea4335;
  --yellow: #fbbc05;
  --green:  #34a853;
  --gray:   #9aa0a6;
  --bg:     #fff;
  --surface:#f8f9fa;
  --border: #dfe1e5;
  --text:   #202124;
  --sub:    #5f6368;
  --radius: 24px;
  --shadow: 0 2px 5px 1px rgba(64,60,67,.16);
  --shadow-hover: 0 4px 11px 3px rgba(64,60,67,.2);
}

html {
  overflow-x: clip;
  width: 100%;
}

body {
  height: 100%;
  font-family: 'Roboto', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow-x: clip;
  width: 100%;
}

/* ===== PAGE SYSTEM ===== */
.page { display: none; min-height: 100vh; width: 100%; overflow-x: clip; }
.page.active { display: flex; flex-direction: column; }

/* ===== LANDING PAGE ===== */
.landing-top-bar {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px;
  gap: 10px;
}

.top-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--sub);
  padding: 6px 12px;
  border-radius: 4px;
  transition: background 0.15s;
  font-family: inherit;
}
.top-link:hover { background: var(--surface); }

.landing-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px 80px;
}

/* ===== LOGO ===== */
.logo-wrap {
  display: flex;
  align-items: baseline;
  line-height: 1;
  margin-bottom: 6px;
  user-select: none;
}

.logo-char {
  font-family: 'Product Sans', 'Roboto', sans-serif;
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -2px;
}
.logo-space { display: inline-block; width: 14px; }

.c1 { color: var(--blue);   }
.c2 { color: var(--red);    }
.c3 { color: var(--yellow); }
.c4 { color: var(--green);  }
.c5 { color: var(--blue);   }
.c6 { color: var(--red);    }

.tagline {
  color: var(--sub);
  font-size: 15px;
  margin-bottom: 28px;
  font-weight: 300;
}

/* ===== SEARCH BOX ===== */
.search-box-wrap { width: 100%; max-width: 584px; }

.search-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  gap: 10px;
  background: #fff;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.search-box:hover,
.search-box:focus-within {
  box-shadow: var(--shadow);
  border-color: transparent;
}

.search-icon { display: flex; align-items: center; flex-shrink: 0; }

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
  background: transparent;
  caret-color: var(--blue);
}
.search-box input::placeholder { color: var(--gray); }

.mic-btn, .send-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.15s;
  flex-shrink: 0;
}
.mic-btn:hover, .send-btn:hover { background: var(--surface); }

/* ===== LANDING BUTTONS ===== */
.landing-btns {
  margin-top: 28px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.g-btn {
  background: var(--surface);
  border: 1px solid var(--surface);
  color: var(--sub);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.ask-steve-btn {
  font-size: 17px;
  padding: 16px 44px;
  background: #e2e5e9;
  border-color: #e2e5e9;
  color: var(--text);
}
.ask-steve-btn:hover {
  background: #d4d7db;
  border-color: #d4d7db;
}
.g-btn:hover {
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  color: var(--text);
}
.g-btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.g-btn.primary:hover { background: #357ae8; border-color: #357ae8; box-shadow: var(--shadow); }
.g-btn.danger { color: var(--red); }
.g-btn.danger:hover { border-color: var(--red); }

/* ===== LANDING FOOTER ===== */
.landing-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}
.footer-links {
  display: flex;
  gap: 20px;
  justify-content: center;
}
.footer-links a {
  color: var(--sub);
  text-decoration: none;
  font-size: 13px;
}
.footer-links a:hover { text-decoration: underline; }

/* ===== CHAT PAGE ===== */
#chat-page {
  display: none;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}
#chat-page.active { display: flex; }

.chat-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  overflow: hidden;
}

.chat-header-logo {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  flex-shrink: 0;
  user-select: none;
}
.chat-header-logo .logo-char { font-size: 24px; letter-spacing: -0.5px; }
.chat-header-logo .logo-space { width: 4px; }

.chat-search-box-wrap { width: 100%; max-width: 584px; min-width: 0; overflow: hidden; }

.chat-search-box { padding: 8px 14px; }
.chat-search-box input { font-size: 15px; }

/* ===== CHAT LOGO BANNER ===== */
.chat-logo-banner {
  display: flex;
  justify-content: center;
  width: 100%;
  cursor: pointer;
}
.chat-logo-banner .logo-wrap {
  margin-bottom: 0;
}

/* ===== MESSAGES ===== */
.chat-messages {
  flex: 1;
  max-width: 760px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
}

.msg-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeUp 0.25s ease both;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-wrap.user { align-items: flex-end; }
.msg-wrap.bot  { align-items: flex-start; }

.msg-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray);
  padding: 0 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-bubble {
  max-width: 80%;
  min-width: 0;
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.msg-wrap.user .msg-bubble {
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-wrap.bot .msg-bubble {
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-indicator span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray);
  animation: bounce 1.2s infinite;
  display: block;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Bot icon */
.bot-icon {
  width: 24px;
  height: auto;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Formatted response text */
.msg-bubble p { margin: 0 0 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble code {
  background: rgba(0,0,0,.07);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}
.msg-bubble pre {
  background: rgba(0,0,0,.06);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble strong { font-weight: 500; }
.msg-bubble ul, .msg-bubble ol {
  margin: 6px 0 10px 20px;
}
.msg-bubble li { margin-bottom: 4px; }

/* ===== API KEY MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal h2 { font-size: 20px; margin-bottom: 10px; color: var(--text); }
.modal p  { color: var(--sub); margin-bottom: 20px; line-height: 1.5; font-size: 13px; }

.modal input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 16px;
}
.modal input:focus { border-color: var(--blue); }

.modal-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bdc1c6; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  html, body, .page, #landing, #chat-page {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: clip !important;
  }

  /* Landing */
  .landing-center { padding: 0 16px 60px; width: 100%; }
  .logo-char { font-size: 28px; letter-spacing: -0.5px; }
  .logo-wrap { flex-wrap: wrap; justify-content: center; width: 100%; }
  .logo-space { width: 5px; }
  .search-box-wrap { width: 100%; max-width: 100%; }
  .search-box { padding: 10px 12px; width: 100%; max-width: 100%; }
  .search-box input { font-size: 16px; width: 0; flex: 1; }
  .ask-steve-btn { width: 100%; font-size: 16px; padding: 15px 20px; }
  .landing-btns { width: 100%; padding: 0; }

  /* Chat header */
  .chat-header {
    padding: 8px 10px;
    gap: 0;
    width: 100%;
  }
  .chat-header-logo { display: none; }
  .chat-search-box-wrap { width: 100%; max-width: 100%; flex: 1; }
  .chat-search-box { padding: 8px 10px; width: 100%; max-width: 100%; }
  .chat-search-box input { font-size: 15px; width: 0; flex: 1; }

  /* Messages */
  .chat-messages {
    padding: 16px 12px 80px;
    width: 100%;
    max-width: 100%;
  }
  .msg-wrap { width: 100%; max-width: 100%; }
  .msg-bubble { max-width: 85%; font-size: 14px; padding: 10px 14px; }

  /* Footer */
  .landing-footer { padding: 12px 16px; width: 100%; }
}
