:root{--background:#F5E6DA;--surface:#F7F1EA;--surface-alt:#F7CD8E;--text:#2D3544;--text-muted:#5C5E56;--accent:#071F40;--accent-text:#F7F1EA;--user-bubble:#D69A82;--border:#5C5E56;--focus:#041C3D;--font-heading:Montserrat, 'Segoe UI', system-ui, -apple-system, sans-serif;--font-body:Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;color-scheme:light}
/* Layout and components. Brand colours and fonts come from the product's
   theme in product.json, written as CSS variables at the top of the built file. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; line-height: 1.25; }
a { color: var(--accent); text-underline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-text); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brand { margin: 0; font-size: 1.2rem; }
.icon-button {
  min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: transparent; color: var(--text); font-size: 1.2rem; cursor: pointer;
}

main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 720px; margin: 0 auto; }
.panel { padding: 24px 16px; }
.center { text-align: center; }
.muted { color: var(--text-muted); }
.small { font-size: 0.9rem; }
.status { margin: 8px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-alt); border: 1px solid var(--border); }
.status[data-kind="error"] { border-color: var(--focus); }

label { display: block; font-weight: 600; margin: 16px 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-height: 48px;
}
button { font: inherit; }
.primary {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 18px;
  margin-top: 14px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-text);
  font-weight: 600; cursor: pointer;
}
.primary:disabled { opacity: 0.6; cursor: progress; }
.link-button { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 12px 0; min-height: 44px; cursor: pointer; }

/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.log { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.bubble p { margin: 0 0 0.6em; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0.2em 0 0.6em; padding-left: 1.3em; }
.msg-user .bubble { background: var(--user-bubble); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg-assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg-notice .bubble { background: var(--surface-alt); border: 1px dashed var(--accent); }
.thinking { color: var(--text-muted); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.starters { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 8px; }
.welcome { margin: 0 0 4px; color: var(--text-muted); }
.starter {
  text-align: left; min-height: 48px; padding: 10px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.starter:hover { border-color: var(--accent); }

.composer {
  position: sticky; bottom: 0; display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--background);
  border-top: 1px solid var(--border);
}
.composer textarea { flex: 1 1 200px; resize: none; max-height: 40dvh; field-sizing: content; }
.send { margin-top: 0; }
.counter { width: 100%; order: 3; font-size: 0.85rem; color: var(--text-muted); }

/* Menu */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  border: 1px solid var(--border); border-radius: 18px; padding: 16px 20px 20px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.menu-head { display: flex; align-items: center; justify-content: space-between; }
.menu-head h2 { margin: 0; }
dialog > button, .menu-link {
  display: block; width: 100%; text-align: left; margin-top: 10px; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer;
  text-decoration: none; line-height: 1.6;
}
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0 6px; }
.note { min-height: 1.5em; margin: 12px 0 0; color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Consent */
.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; }
.check input { width: 24px; min-height: 24px; height: 24px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.check label { margin: 0; font-weight: 600; }
