:root {
  --brand: #0d3b25;        /* Clare Energy Agency dark green */
  --brand-ink: #ffffff;
  --accent: #198754;
  --tint: #e8f5ee;
  --ink: #1f2a24;
  --muted: #5f6b64;
  --line: #d9e3dd;
  --bg: #ffffff;
  --err: #a3271f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink);
       font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chat { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; }
body.embed .chat { max-width: none; }

.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
             padding: 12px 16px; background: var(--brand); color: var(--brand-ink); }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: grid; place-items: center;
          font-weight: 700; font-size: 17px; flex: none; }
.chat-head h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.chat-head p { font-size: 12px; margin: 2px 0 0; opacity: .85; }
.close { background: none; border: 0; color: inherit; font-size: 26px; line-height: 1; padding: 4px 8px; cursor: pointer;
         border-radius: 6px; }
.close:hover, .close:focus-visible { background: rgba(255,255,255,.15); }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; overflow-wrap: anywhere; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; } .msg li { margin: 2px 0; }
.msg.bot { align-self: flex-start; background: var(--tint); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px;
            white-space: pre-wrap; }
.msg.error { background: #fdecea; color: var(--err); }
.msg a { color: var(--accent); }
.msg sup a { text-decoration: none; font-weight: 600; padding: 0 1px; }
.sources { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.sources strong { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.sources ol { margin: 0; padding-left: 20px; } .sources li { margin: 2px 0; }

.typing { align-self: flex-start; background: var(--tint); border-radius: 14px; padding: 12px 14px; display: flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; 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; } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; opacity: .7; } }

.composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
                     font: inherit; color: inherit; max-height: 140px; min-height: 40px; }
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.composer button { flex: none; width: 42px; height: 42px; border-radius: 10px; border: 0; background: var(--accent);
                   color: #fff; cursor: pointer; display: grid; place-items: center; align-self: flex-end; }
.composer button:disabled { opacity: .5; cursor: default; }

.notice { font-size: 11.5px; color: var(--muted); padding: 0 14px 10px; line-height: 1.4; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
