:root {
  --bg: #0f1420;
  --panel: #161d2e;
  --border: #263048;
  --text: #e8ecf6;
  --muted: #94a0bd;
  --accent: #22c55e;
  --accent-dim: #14532d;
  --danger: #f87171;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  background: var(--accent);
  color: #06140a;
  font-weight: 800;
  border-radius: 10px;
  padding: 8px 10px;
  letter-spacing: 0.5px;
}
.brand h1 { font-size: 18px; }
.tagline { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.quota-badge {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: #bbf7d0;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.quota-badge.low { border-color: var(--danger); color: #fecaca; background: #3b1212; }

.chat-wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.disclaimer-bar {
  background: #1d2436;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 2px;
  min-height: 320px;
  max-height: 56vh;
}

.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.bot { justify-content: flex-start; }

.bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14.5px;
  white-space: normal;
  word-wrap: break-word;
}
.msg.user .bubble { background: var(--accent); color: #06140a; border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.bubble a { color: #7dd3fc; text-decoration: underline; }
.bubble a:visited { color: #b8a1f7; }
.bubble strong { font-weight: 700; }
.bubble em { font-style: italic; }
.bubble .src { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }

.typing::after { content: "…"; animation: dots 1.2s steps(3, end) infinite; }
@keyframes dots { 0% { content: ""; } 33% { content: "."; } 66% { content: ".."; } 100% { content: "…"; } }

.input-row { display: flex; gap: 10px; }
.input-row input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 15px;
  font-size: 15px;
  outline: none;
}
.input-row input:focus { border-color: var(--accent); }
.input-row button {
  background: var(--accent);
  color: #06140a;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  padding: 0 22px;
  cursor: pointer;
}
.input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.fineprint {
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}
.fineprint a { color: var(--muted); }

/* Buy us a coffee */
.support-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: #1a2233;
}
.support-text { font-size: 14px; color: var(--muted); font-weight: 600; }
.support-img { height: 72px; width: auto; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.bmc-footer { text-align: center; padding: 6px 0 12px; }
.bmc-img { height: 60px; width: auto; border-radius: 10px; opacity: 1; }
.bmc-img:hover { opacity: 0.9; transform: scale(1.03); }

@media (max-width: 560px) {
  .topbar { padding: 12px 14px; }
  .chat-wrap { padding: 12px; }
  .bubble { max-width: 94%; }
}
