/* ===========================================================================
   KateAI — member front end
   Warm, calm, simple. Mobile-first. Large tap targets.

   >>> BRANDING PLACEHOLDERS <<<
   Replace the values in :root with Life with Kate's real colors, and swap the
   font + logo in index.php. Everything theme-related is a token here.
   =========================================================================== */
:root {
  --brand:        #6B9080;  /* PLACEHOLDER primary (calm sage)  */
  --brand-dark:   #52735f;
  --accent:       #E8C4A2;  /* PLACEHOLDER warm accent          */
  --bg:           #FBF7F0;  /* PLACEHOLDER warm cream page bg    */
  --surface:      #FFFFFF;
  --surface-2:    #F3EFE8;
  --ink:          #3A3A3A;
  --muted:        #7C7A75;
  --line:         #E7E1D6;
  --user-bubble:  #6B9080;
  --user-ink:     #FFFFFF;
  --bot-bubble:   #F3EFE8;
  --bot-ink:      #3A3A3A;
  --danger:       #B5543E;
  --radius:       18px;
  --shadow:       0 2px 10px rgba(0,0,0,.06);
  --font:         'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --maxw:         780px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100dvh;
}
button { font: inherit; cursor: pointer; }
a { color: var(--brand-dark); }

/* ---- App shell ----------------------------------------------------------- */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .logo { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; }
.logo svg, .logo-lg svg { display: block; width: 100%; height: 100%; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.iconbtn {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 18px; color: var(--ink);
}
.program-filter { border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 12px; min-height: 40px; padding: 0 10px; color: var(--ink); max-width: 46vw; }

/* ---- Layout: main + drawer ---------------------------------------------- */
.main { flex: 1; display: flex; flex-direction: column; width: 100%;
  max-width: var(--maxw); margin: 0 auto; padding: 0 14px; width: 100%; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; }
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed; top: 0; left: 0; height: 100dvh; width: 300px; max-width: 86vw;
  background: var(--surface); border-right: 1px solid var(--line); z-index: 41;
  transform: translateX(-100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer header { padding: 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.drawer header strong { font-size: 15px; }
.newchat { width: 100%; background: var(--brand); color: #fff; border: 0; border-radius: 12px;
  padding: 12px; margin: 12px 0 4px; font-weight: 600; }
.convlist { flex: 1; overflow-y: auto; padding: 6px 8px 20px; }
.convitem { display: flex; align-items: center; gap: 6px; padding: 10px 10px; border-radius: 10px; }
.convitem:hover { background: var(--surface-2); }
.convitem.active { background: var(--surface-2); }
.convitem .title { flex: 1; font-size: 14px; border: 0; background: transparent; text-align: left;
  color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 32px; }
.convitem .mini { background: transparent; border: 0; color: var(--muted); padding: 4px 6px; font-size: 14px; }

/* ---- Welcome / starters -------------------------------------------------- */
.welcome { text-align: center; padding: 34px 6px 10px; }
.welcome .logo-lg { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 14px; }
.welcome h2 { margin: 0 0 6px; font-size: 24px; }
.welcome p { color: var(--muted); margin: 0 auto; max-width: 440px; line-height: 1.55; }
.starters { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 22px auto 0; max-width: 520px; }
@media (min-width: 560px){ .starters { grid-template-columns: 1fr 1fr; } }
.starter {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; text-align: left; font-size: 15px; color: var(--ink);
  box-shadow: var(--shadow); min-height: 56px;
}
.starter:hover { border-color: var(--brand); }

/* ---- Chat thread --------------------------------------------------------- */
.thread { flex: 1; overflow-y: auto; padding: 16px 0 10px; display: none; flex-direction: column; gap: 14px; }
.msg { max-width: 86%; line-height: 1.6; }
.msg.user { align-self: flex-end; }
.msg.bot  { align-self: flex-start; }
.bubble { padding: 12px 15px; border-radius: var(--radius); box-shadow: var(--shadow); }
.msg.user .bubble { background: var(--user-bubble); color: var(--user-ink); border-bottom-right-radius: 6px; }
.msg.bot  .bubble { background: var(--bot-bubble); color: var(--bot-ink); border-bottom-left-radius: 6px; }
.bubble p { margin: 0 0 10px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 20px; }
.bubble li { margin: 3px 0; }
.bubble h3 { font-size: 16px; margin: 6px 0; }
.bubble a { color: inherit; text-decoration: underline; }

.sources { margin-top: 8px; font-size: 13px; }
.sources .label { color: var(--muted); margin-bottom: 4px; }
.sources a { display: inline-block; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px; margin: 0 6px 6px 0; text-decoration: none; color: var(--brand-dark); }

.rate { margin-top: 6px; display: flex; gap: 6px; }
.rate button { background: transparent; border: 1px solid var(--line); border-radius: 10px;
  min-width: 40px; min-height: 34px; font-size: 15px; }
.rate button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span { width: 8px; height: 8px; 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%,100%{opacity:.25;transform:translateY(0)} 50%{opacity:1;transform:translateY(-2px)} }

/* ---- Composer + disclaimer ---------------------------------------------- */
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 6px; }
.composer .box { display: flex; align-items: flex-end; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 24px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); }
.composer textarea { flex: 1; border: 0; resize: none; font: inherit; background: transparent;
  max-height: 140px; min-height: 24px; padding: 8px 0; outline: none; color: var(--ink); }
.composer .send { background: var(--brand); color: #fff; border: 0; border-radius: 50%;
  width: 44px; height: 44px; font-size: 18px; flex: 0 0 auto; }
.composer .send:disabled { opacity: .5; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 8px 12px; }

.notice { max-width: 520px; margin: 10px auto; background: #FFF7E8; border: 1px solid #F0E0B8;
  color: #7a5e14; border-radius: 12px; padding: 12px 14px; font-size: 14px; text-align: center; }

/* ---- Auth (login) screen ------------------------------------------------- */
.auth { max-width: 420px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px; box-shadow: var(--shadow); text-align: center; }
.auth .logo-lg { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px; }
.auth h2 { margin: 0 0 6px; } .auth p { color: var(--muted); line-height: 1.55; }
.auth input { width: 100%; padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px;
  font: inherit; margin-top: 14px; }
.auth button.primary { width: 100%; background: var(--brand); color: #fff; border: 0;
  border-radius: 14px; padding: 14px; margin-top: 12px; font-weight: 600; min-height: 48px; }
.auth .msg { margin-top: 12px; font-size: 14px; line-height: 1.5; }

.hidden { display: none !important; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; }
