/* Mariam web chat. Safaricom-style green, no Safaricom artwork (docs/06). */
:root {
  --green: #43b02a;
  --green-strong: #2f8a1c;
  --green-deep: #1d5c12;
  --green-tint: #eaf6e6;
  --bg: #f3f6f2;
  --surface: #ffffff;
  --surface-2: #f7f9f6;
  --text: #17201a;
  --muted: #5b6b5f;
  --border: #dde5da;
  --bubble-me: #43b02a;
  --bubble-me-text: #ffffff;
  --bubble-bot: #ffffff;
  --code-bg: #eaf6e6;
  --code-text: #1d5c12;
  --warn-bg: #fff6e0;
  --warn-text: #6b4a00;
  --shadow: 0 1px 2px rgba(16, 40, 16, .06), 0 8px 24px rgba(16, 40, 16, .08);
  --radius: 18px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1510; --surface: #152019; --surface-2: #1a281f; --text: #e8f0e9; --muted: #9db3a2;
    --border: #253629; --bubble-bot: #1b2a20; --green-tint: #1c3320; --code-bg: #1f3a23; --code-text: #b8f0a6;
    --warn-bg: #3a2f12; --warn-text: #f3d68a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1510; --surface: #152019; --surface-2: #1a281f; --text: #e8f0e9; --muted: #9db3a2;
  --border: #253629; --bubble-bot: #1b2a20; --green-tint: #1c3320; --code-bg: #1f3a23; --code-text: #b8f0a6;
  --warn-bg: #3a2f12; --warn-text: #f3d68a; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; -webkit-text-size-adjust: 100%;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(90deg, var(--green-deep), var(--green-strong) 60%, var(--green));
  color: #fff; position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--green-strong);
  display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none;
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.brand p { margin: 0; font-size: 13px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.4); white-space: nowrap;
}
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff; font-weight: 500; font-size: 14px;
}
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-ghost svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }

/* ---- layout ---- */
.layout { flex: 1; display: flex; min-height: 0; width: 100%; max-width: 1200px; margin: 0 auto; gap: 20px; padding: 0; }
.side { display: none; }
.chat {
  flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--surface);
}

/* ---- messages ---- */
.messages {
  flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain; scroll-behavior: smooth;
}
.msg { display: flex; gap: 8px; max-width: 100%; animation: pop .18s ease-out; }
.msg .mini {
  width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; margin-top: 2px;
}
.bubble {
  padding: 10px 14px; border-radius: var(--radius); max-width: min(78ch, 85%);
  overflow-wrap: anywhere; word-break: normal; font-size: 15.5px;
}
.bot .bubble { background: var(--bubble-bot); border: 1px solid var(--border); border-top-left-radius: 6px; box-shadow: var(--shadow); }
.me { justify-content: flex-end; }
.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); border-top-right-radius: 6px; }
.bubble code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .92em; padding: 1px 6px; border-radius: 6px;
  background: var(--code-bg); color: var(--code-text); white-space: nowrap;
}
.me .bubble code { background: rgba(255,255,255,.22); color: #fff; }
.bubble strong { font-weight: 600; }
.note { align-self: center; font-size: 13px; color: var(--warn-text); background: var(--warn-bg); padding: 6px 12px; border-radius: 10px; text-align: center; }
.typing .bubble { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg, .typing span { animation: none; } .messages { scroll-behavior: auto; } }

/* ---- chips ---- */
.chips { display: flex; gap: 8px; padding: 4px 16px 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--green); background: var(--green-tint);
  color: var(--text); font-size: 14px; font-weight: 500;
}
.chip:hover { background: var(--green); color: #fff; }

/* ---- composer ---- */
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border);
  background: var(--surface);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 22px; padding: 11px 16px; max-height: 140px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming in */ color: var(--text); background: var(--surface-2); line-height: 1.4;
  overflow-y: hidden; /* app.js turns scrolling on only past the maximum height */
}
.composer textarea::placeholder { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer textarea:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-tint); }
.send {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--green); color: #fff; flex: none;
  display: grid; place-items: center; transition: background .15s;
}
.send:hover { background: var(--green-strong); }
.send:disabled { opacity: .5; cursor: default; }
.send svg { width: 22px; height: 22px; fill: currentColor; }
.disclaimer {
  margin: 0; padding: 4px 16px calc(8px + env(safe-area-inset-bottom)); font-size: 11.5px; color: var(--muted);
  text-align: center; background: var(--surface);
}

/* ---- side panel (laptops and up) ---- */
.side h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.services { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.services button {
  width: 100%; display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.services button:hover { border-color: var(--green); transform: translateY(-1px); }
.services .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--green-tint); display: grid; place-items: center; flex: none; font-size: 18px; }
.services strong { display: block; font-size: 15px; }
.services small { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; margin-top: 2px; }
.safety { margin-top: 16px; padding: 14px; border-radius: 14px; background: var(--warn-bg); color: var(--warn-text); font-size: 13.5px; }
.safety p { margin: 4px 0 0; }

/* phones: compact header */
@media (max-width: 480px) {
  .brand p { display: none; }
  .btn-ghost span { display: none; }
  .btn-ghost { padding: 8px; }
  .badge { font-size: 11px; padding: 3px 8px; }
  .bubble { max-width: 88%; }
}

/* tablets: centred card */
@media (min-width: 640px) {
  .layout { padding: 20px; }
  .chat { border-radius: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; max-width: 760px; margin: 0 auto; }
  .disclaimer { padding-bottom: 10px; }
}

/* laptops and desktops: side panel */
@media (min-width: 1024px) {
  .layout { padding: 24px; }
  .side { display: block; width: 320px; flex: none; overflow-y: auto; }
  .chat { max-width: none; margin: 0; }
  .topbar { padding-left: max(24px, calc((100vw - 1200px) / 2 + 24px)); padding-right: max(24px, calc((100vw - 1200px) / 2 + 24px)); }
}

/* large monitors */
@media (min-width: 1600px) {
  body { font-size: 17px; }
  .bubble { font-size: 16.5px; }
  .layout { max-width: 1320px; }
  .side { width: 360px; }
  .topbar { padding-left: calc((100vw - 1320px) / 2 + 24px); padding-right: calc((100vw - 1320px) / 2 + 24px); }
}
