/* A Recomend — end-user chat. Reads like a real messaging app (DESIGN.md).
   Tokens, base, buttons and the topbar come from auth.css (loaded first). */

body { display: flex; flex-direction: column; }

/* Topbar meter -------------------------------------------------------------- */
.know {
  display: flex; flex-direction: column; gap: var(--s1); min-width: 150px;
  font-size: 11px; color: var(--muted);
}
.know-label { display: flex; justify-content: space-between; gap: var(--s2); font-weight: 600; }
.know-bar { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.know-bar > span { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .2s ease; }
.obs { font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.obs.ready { color: var(--accent-press); font-weight: 700; }
.facts { display: inline-flex; align-items: center; gap: var(--s2); font-size: 10px; margin-top: 2px; }
.facts .fact-chip { display: inline-flex; align-items: center; gap: 3px; }
.facts .ic { width: 13px; height: 13px; color: var(--muted); }

/* Conversation -------------------------------------------------------------- */
.chat { flex: 1 1 auto; overflow-y: auto; padding: var(--s5) var(--s4); }
.chat-inner { max-width: 68ch; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s4); }

.intro {
  color: var(--muted); font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: var(--s5);
}
.intro h2 { margin: 0 0 var(--s1); font-size: 20px; font-weight: 600; color: var(--ink); }
.intro .ex { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.intro .ex button {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  font-size: 13px; height: 34px; padding: 0 var(--s3); border-radius: var(--r-pill);
}
.intro .ex button:hover { background: var(--accent-weak); border-color: var(--accent-weak); }

/* Message rows + bubbles */
.msg { display: flex; flex-direction: column; max-width: 82%; gap: 2px; }
.msg.user { align-self: flex-start; }
html[dir="ltr"] .msg.user { align-self: flex-end; }
.msg.bot { align-self: flex-end; }
html[dir="ltr"] .msg.bot { align-self: flex-start; }

.bubble {
  padding: 10px 14px; border-radius: var(--r-card); font-size: 15px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.7;
}
.msg.user .bubble { background: var(--accent-weak); color: var(--ink); border-end-end-radius: 4px; }
.msg.bot .bubble { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-end-start-radius: 4px; }
.bubble.typing { color: var(--muted); font-style: italic; }
.msg-time { font-size: 12px; color: var(--muted); padding: 0 4px; }
.msg.user .msg-time { text-align: start; }
.msg.bot .msg-time { text-align: end; }

/* History lazy-load: brief marker while an older page is being fetched. */
.history-loading {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: var(--s1) 0; letter-spacing: 2px;
}

/* Intent chip */
.intent-chip {
  display: inline-flex; align-items: center; gap: var(--s1); align-self: flex-end;
  margin-top: var(--s1); font-size: 11px; font-weight: 600;
  background: var(--accent-weak); color: var(--accent-press);
  padding: 3px 10px; border-radius: var(--r-pill);
}
html[dir="ltr"] .intent-chip { align-self: flex-start; }
.intent-chip code { background: var(--surface); padding: 1px 6px; border-radius: 5px; font-size: 11px; }

/* Recommendation items — a compact list INSIDE the assistant bubble.
   Reply text on top, then hairline-divided rows:
   40px thumb · title + one muted meta line · ghost Shop icon-link. */
.bubble.has-items { align-self: stretch; }
.bubble-text { white-space: pre-wrap; }
.item-list {
  margin-top: var(--s2); border-top: 1px solid var(--line); white-space: normal;
}
.item-row {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 56px; padding: var(--s2) 0; cursor: pointer;
}
.item-row + .item-row { border-top: 1px solid var(--line); }
.item-row:hover .item-title { color: var(--accent-press); }
.item-thumb {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: var(--r-btn);
  background: var(--bg); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--muted); overflow: hidden;
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-thumb .ic { width: 18px; height: 18px; }
.item-main { flex: 1 1 auto; min-width: 0; }
.item-title {
  font-size: 14px; font-weight: 600; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-meta {
  margin-top: 2px; display: flex; align-items: center; gap: var(--s3);
  font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap;
}
.item-price { font-weight: 600; white-space: nowrap; }
.item-dist { display: inline-flex; align-items: center; gap: 4px; }
.item-dist .ic { width: 14px; height: 14px; }
.item-color { display: inline-flex; align-items: center; gap: 5px; }
.item-color .swatch { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
/* Place rows: the thumb+text wrap in a Google Maps directions anchor. It lays
   out exactly like the bare row content and inherits ink color; a small muted
   location glyph marks rows that navigate. */
.item-nav {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--s3);
  color: inherit; text-decoration: none;
}
.item-nav-ic { flex: 0 0 auto; display: inline-flex; color: var(--muted); }
.item-nav-ic .ic { width: 14px; height: 14px; }
.item-shop {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-btn);
  color: var(--accent); text-decoration: none;
}
.item-shop:hover { color: var(--accent-press); background: var(--accent-weak); }
.item-shop .ic { width: 16px; height: 16px; }
.learned-tick {
  flex: 0 0 auto; display: inline-flex; align-items: center;
  color: var(--accent-press); opacity: 0; transition: opacity .16s ease;
}
.learned-tick .ic { width: 14px; height: 14px; }
.item-row.learned .learned-tick { opacity: 1; }

.shopper-note {
  display: flex; align-items: flex-start; gap: var(--s2); white-space: normal;
  font-size: 13px; color: var(--ink); background: var(--accent-weak);
  border-radius: var(--r-btn); padding: var(--s2) var(--s3); margin: var(--s2) 0 0;
}
.shopper-note .ic { width: 16px; height: 16px; color: var(--accent); margin-top: 2px; }
.more-btn {
  display: inline-flex; align-items: center; margin-top: var(--s2); height: 34px;
  padding: 0 var(--s3); border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 13px; color: var(--accent-press);
}
.more-btn:hover { background: var(--accent-weak); border-color: var(--accent-weak); }

/* Inline checklist card (chat thread) — always synced to the server's list.
   It lives INSIDE the assistant bubble, below the reply text / item rows,
   separated by a hairline (no card chrome of its own). */
.checklist-card {
  margin-top: var(--s2); padding-top: var(--s2);
  border-top: 1px solid var(--line); white-space: normal;
}
/* Checklist-only reply (empty text, no items): nothing above → no hairline. */
.bubble-text:empty + .checklist-card { border-top: 0; margin-top: 0; padding-top: 0; }
.checklist-head {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.checklist-head .ic { width: 16px; height: 16px; color: var(--accent); flex: 0 0 auto; }
.checklist-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist-from { font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.checklist-count { font-size: 12px; font-weight: 600; color: var(--muted); }
.checklist-items { display: flex; flex-direction: column; margin-top: var(--s2); }
.checklist-item {
  display: flex; align-items: center; gap: var(--s3); text-align: start;
  background: none; border: 0; border-top: 1px solid var(--line);
  padding: var(--s2) 2px; font-size: 14px; color: var(--ink); cursor: pointer;
}
.checklist-item:first-child { border-top: 0; }
.checklist-box {
  width: 18px; height: 18px; flex: 0 0 auto; display: inline-flex;
  align-items: center; justify-content: center;
  border: 1.5px solid var(--muted); border-radius: 5px; background: var(--surface);
  transition: background .16s ease, border-color .16s ease;
}
.checklist-box .ic { width: 12px; height: 12px; color: #fff; }
.checklist-item.checked .checklist-box { background: var(--accent); border-color: var(--accent); }
.checklist-item.checked .checklist-text { color: var(--muted); text-decoration: line-through; }
/* Completed (or deleted server-side): frozen, read-only. */
.checklist-card.completed { opacity: .65; }
.checklist-card.completed .checklist-item { cursor: default; }

/* Banners & proactive questions */
.pro-banner, .reminder-banner {
  align-self: stretch; display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); border-radius: var(--r-card); font-weight: 600; font-size: 14px;
  border: 1px solid var(--line); background: var(--surface);
}
.pro-banner { background: var(--accent-weak); border-color: var(--accent-weak); color: var(--accent-press); }
.pro-banner .ic, .reminder-banner .ic { width: 18px; height: 18px; }
.reminder-banner { color: var(--ink); }
.reminder-banner .ic { color: var(--accent); }

.pro-question {
  align-self: stretch; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: var(--s4);
}
.pro-question-text { display: flex; align-items: flex-start; gap: var(--s2); margin: 0 0 var(--s3); font-size: 14px; font-weight: 600; color: var(--ink); }
.pro-question-text .ic { width: 18px; height: 18px; color: var(--accent); margin-top: 2px; }
.pro-question-actions { display: flex; gap: var(--s2); }
.pro-question-actions button {
  flex: 1; height: 40px; border-radius: var(--r-btn); border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 13px; color: var(--ink);
}
.pro-question-actions button:hover { background: var(--accent-weak); border-color: var(--accent-weak); }
.pro-question-actions button:first-child { background: var(--accent); color: #fff; border-color: transparent; }
.pro-question-actions button:first-child:hover { background: var(--accent-press); }
.pro-question-done { display: flex; align-items: center; gap: var(--s1); margin: var(--s2) 0 0; font-size: 13px; color: var(--accent-press); font-weight: 600; }
.pro-question-done .ic { width: 15px; height: 15px; }
.profile-q, .status-q { background: var(--surface); }

/* Overlays (about / family) ------------------------------------------------ */
.about-overlay {
  position: fixed; inset: 0; background: rgba(20,18,15,.35);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: var(--s5);
}
.about-overlay.hidden { display: none; }
.about-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--overlay-shadow);
  width: min(460px, 100%); max-height: 80vh; overflow-y: auto; padding: var(--s5);
}
.about-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s3); }
.about-head h3 { margin: 0; font-size: 20px; font-weight: 600; }
.about-portrait { font-size: 15px; line-height: 1.7; color: var(--ink); margin: 0 0 var(--s3); }
.about-conf { font-size: 12px; font-weight: 600; color: var(--accent-press); margin-bottom: var(--s3); }
.about-insights { margin: 0; padding-inline-start: var(--s5); }
.about-insights li { font-size: 14px; color: var(--ink); margin: var(--s1) 0; }
.about-empty { font-size: 14px; color: var(--muted); }
.about-facts-title { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: var(--s4) 0 var(--s2); border-top: 1px solid var(--line); padding-top: var(--s3); }
.about-facts { display: flex; flex-direction: column; gap: var(--s2); }
.fact-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.fact-label { font-size: 13px; color: var(--ink); font-weight: 600; }
.fact-input { flex: 0 1 150px; font-size: 13px; }

/* Upcoming-reminders overlay (bell) */
.rem-section-title {
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: var(--s4) 0 var(--s2);
}
.rem-section-title:first-child { margin-top: 0; }
.rem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.rem-item {
  display: flex; align-items: flex-start; gap: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s3);
}
.rem-item > .ic { width: 18px; height: 18px; color: var(--accent); flex: 0 0 auto; margin-top: 2px; }
.rem-main { flex: 1 1 auto; min-width: 0; }
.rem-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.rem-when {
  margin: 2px 0 0; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.rem-when .ic { width: 13px; height: 13px; flex: 0 0 auto; }
.rem-times { direction: ltr; unicode-bidi: isolate; }
.rem-chip {
  font-size: 11px; font-weight: 600; background: var(--accent-weak); color: var(--accent-press);
  padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap;
}
.rem-del { flex: 0 0 auto; }
.rem-del .ic { width: 16px; height: 16px; }
.rem-stop { flex: 0 0 auto; height: 30px; padding: 0 var(--s3); font-size: 12px; }
.rem-loading { text-align: center; color: var(--muted); letter-spacing: 2px; margin: var(--s3) 0; }
.rem-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  padding: var(--s5) 0; color: var(--muted); text-align: center;
}
.rem-empty .ic { width: 28px; height: 28px; }
.rem-empty p { margin: 0; font-size: 14px; }

.fam-idrow { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.fam-idlabel { font-size: 12px; color: var(--muted); font-weight: 600; }
.fam-id { font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; word-break: break-all; }
.fam-idrow .ghost { height: 32px; }
.fam-add { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.fam-add input { flex: 1 1 120px; font-size: 13px; }
.fam-add .primary { padding: 0 var(--s4); }

/* Composer ------------------------------------------------------------------ */
.composer { flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--surface); padding: var(--s3) var(--s4); }
.composer-inner { max-width: 68ch; margin: 0 auto; display: flex; gap: var(--s2); align-items: flex-end; }
.composer textarea {
  flex: 1 1 auto; resize: none; max-height: 140px; min-height: 40px;
  padding: 9px 14px; border-radius: var(--r-card); font: inherit;
}
.composer .send { flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border-radius: var(--r-btn); }
.composer .send .ic { width: 20px; height: 20px; }
html[dir="rtl"] .composer .send .ic { transform: scaleX(-1); }

@media (max-width: 560px) {
  .know { min-width: 120px; }
}
