:root {
  --bg: #f7f9fc;
  --card: #ffffff;
  --primary: #0e7490;
  --primary-2: #155e75;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --success: #22c55e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.titles .title { font-weight: 700; font-size: 20px; }
.titles .subtitle { font-size: 12px; opacity: 0.9; }

.status { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.status .dot {
  width: 10px; height: 10px; border-radius: 50%; background: #22c55e; display: inline-block;
}

.main {
  width: 100%;
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px 120px 16px; /* bottom padding so last messages aren't hidden behind composer */
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.qa-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.05s ease, box-shadow 0.1s ease;
}
.qa-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.qa-title { font-weight: 600; margin-top: 8px; }
.qa-icon { font-size: 20px; color: var(--primary); }

.chat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-height: 340px;
}

.msg { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; width: 100%; }
.msg.user { justify-content: flex-end; }
.msg .bubble {
  padding: 12px 14px;
  border-radius: 12px;
  max-width: 85%;
  white-space: normal;
}
.msg.user .bubble { background: #e5f6ff; border: 1px solid #bae6fd; margin-left: 48px; }
.msg.assistant { justify-content: flex-start; }
.msg.assistant .bubble { background: #f1f5f9; border: 1px solid #e2e8f0; margin-right: 48px; }
.msg .avatar { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; }
.msg.user .avatar { order: 2; }
.msg.user .bubble { order: 1; }

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 6px; height: 6px; background: #94a3b8; border-radius: 50%; display: inline-block; animation: blink 1.4s infinite both; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.msg.user .avatar { background: #dbeafe; }
.msg.assistant .avatar { background: #e2e8f0; }

.composer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 16px 16px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto; /* align with chat container */
  z-index: 20;
}
.hint { color: var(--muted); font-size: 12px; margin-bottom: 8px; text-align: center; }
.input-row { display: flex; gap: 8px; align-items: center; }
input#message-input {
  flex: 1;
  padding: 14px 16px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  font-size: 15px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.send {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 9999px;
  width: 46px;
  height: 46px;
  min-width: 46px;
  display: grid;
  place-items: center;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 46px; /* prevent flex shrinking */
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.send:hover { background: var(--primary-2); }
.

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }


/* Basic markdown styling inside assistant bubbles */
.msg.assistant .bubble h1,
.msg.assistant .bubble h2,
.msg.assistant .bubble h3 { margin: 6px 0 4px; font-size: 1rem; }
.msg.assistant .bubble p { margin: 6px 0; }
.msg.assistant .bubble ul { margin: 6px 0 6px 20px; padding: 0; }
.msg.assistant .bubble li { margin: 4px 0; }
.msg.assistant .bubble code { background: #e2e8f0; padding: 2px 4px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 0.9em; }
.msg.assistant .bubble a { color: var(--primary-2); text-decoration: underline; }

/* Mobile adjustments */
@media (max-width: 640px) {
  .main { padding-bottom: 170px; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .qa-btn { padding: 12px; border-radius: 10px; }
  .qa-title { font-size: 14px; }
  .qa-icon { font-size: 18px; }
  .composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    margin: 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}


