/* He.art AI's widget (D:\dev\heart-ai, widget/heartai.js): the Ask AI button and its panel, shared by our sites and
   pinned per site by HEARTAI.lock. The page sets the colors (--bg --ink --muted --line --tint --link --on-link
   --accent --shadow) and may set --header-h, --to-top-right, --hb-dock-h and --consent-h; the layout ones count as 0 when unset.
   The rules began as Vi.ki's (George, Nov 13, 2026), homes.me's floating button and drawer in Vi.ki's colors. */
.ask-fab {
  position: fixed; right: var(--to-top-right, 1rem); z-index: 42;
  bottom: min(calc(1rem + var(--hb-dock-h, 0px) + var(--consent-h, 0px)), calc(100dvh - var(--header-h, 0px) - 4.5rem));
  display: inline-flex; align-items: center; gap: .55rem; height: 3.1rem; padding: 0 1.4rem;
  border: 2px solid rgba(255, 255, 255, .85); border-radius: 999px; font: inherit; font-size: 1.05rem; font-weight: 700;
  letter-spacing: .01em; cursor: pointer; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  /* Its own warm colors on every site, light or dark (George, Nov 13, 2026: "emphasize the Ask AI button so it is
     clearly visible, the current blue color isn't very visible"): the site's link blue sat too close to its text. A
     site may set --heartai-from and --heartai-to. */
  background: linear-gradient(135deg, var(--heartai-from, #e3103c), var(--heartai-to, #d24f00));
  box-shadow: 0 6px 22px rgba(255, 45, 85, .45), 0 0 0 0 rgba(255, 45, 85, .55);
  transition: opacity .2s, transform .2s, box-shadow .2s;
  animation: heartai-call 3.2s ease-out 1s infinite;
}
.ask-fab svg { width: 20px; height: 20px; }
.ask-fab:hover, .ask-fab:focus-visible { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 28px rgba(255, 45, 85, .6); animation: none; }
/* A soft ring that spreads from the button now and then, so the eye finds it; still for anyone who asks for less motion. */
@keyframes heartai-call {
  0% { box-shadow: 0 6px 22px rgba(255, 45, 85, .45), 0 0 0 0 rgba(255, 45, 85, .55); }
  45%, 100% { box-shadow: 0 6px 22px rgba(255, 45, 85, .45), 0 0 0 14px rgba(255, 45, 85, 0); }
}
.ask-fab.away { opacity: 0; transform: translateY(1rem); pointer-events: none; }
body:has(.ask-fab) .to-top { margin-bottom: calc(var(--consent-h, 0px) + 3.9rem); }
.heartai {
  position: fixed; right: var(--to-top-right, 1rem); z-index: 43;
  bottom: min(calc(1rem + var(--hb-dock-h, 0px) + var(--consent-h, 0px)), calc(100dvh - var(--header-h, 0px) - 4.5rem));
  /* 54rem, half again the first 36rem (George, Nov 13, 2026: "make the ask ai window taller, it is too short for
     reading responses try 50% taller"); a conversation keeps that height, so a long answer has room from the start.
     Never taller than the window allows under the header. */
  width: min(26rem, calc(100vw - 2rem)); max-height: min(54rem, calc(100dvh - var(--header-h, 0px) - var(--hb-dock-h, 0px) - var(--consent-h, 0px) - 2rem));
  display: flex; flex-direction: column; gap: .6rem; padding: 1rem;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  font-size: .95rem;
}
.heartai[hidden] { display: none; }
.heartai:not(.heartai-fresh) { height: min(54rem, calc(100dvh - var(--header-h, 0px) - var(--hb-dock-h, 0px) - var(--consent-h, 0px) - 2rem)); }
.heartai-log { flex: 1; }
.heartai-head { display: flex; align-items: flex-start; gap: .5rem; }
.heartai-head > div { flex: 1; }
.heartai-head small { display: block; color: var(--muted); font-size: .82rem; }
.heartai-close, .heartai-clear, .heartai-earlier {
  border: 1px solid var(--line); background: none; color: var(--ink); border-radius: 999px; cursor: pointer; font: inherit;
}
.heartai-close { width: 2rem; height: 2rem; font-size: 1.2rem; line-height: 1; }
.heartai-clear { height: 2rem; padding: 0 .7rem; font-size: .82rem; color: var(--muted); }
.heartai-fresh .heartai-clear { visibility: hidden; }
.heartai-close:hover, .heartai-clear:hover, .heartai-earlier:hover { border-color: var(--link); color: var(--link); }
.heartai-earlier { height: 2rem; padding: 0 .7rem; font-size: .82rem; color: var(--muted); }
.heartai-earlier[hidden] { display: none; }
.heartai-earlier[aria-expanded="true"] { border-color: var(--link); color: var(--link); }
/* Earlier conversations, put aside by New: a list over the conversation, newest first. */
.heartai-past { display: flex; flex-direction: column; gap: .35rem; max-height: 50%; overflow-y: auto; padding: .5rem; border: 1px solid var(--line); border-radius: 12px; background: var(--tint); }
.heartai-past[hidden] { display: none; }
.heartai-past-head { margin: 0 0 .15rem; font-size: .78rem; color: var(--muted); }
.heartai-past button {
  display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; width: 100%; text-align: left;
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-size: .88rem; cursor: pointer;
}
.heartai-past button:hover { border-color: var(--link); }
.heartai-past button small { flex: none; color: var(--muted); font-size: .75rem; }
.heartai-back { margin: 0; }
.heartai-back[hidden] { display: none; }
.heartai-back button { border: 0; background: none; padding: 0; color: var(--link); font: inherit; font-size: .88rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.heartai-log { overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; min-height: 0; }
.heartai-fresh .heartai-log { display: none; }
.heartai-msg { padding: .55rem .75rem; border-radius: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.heartai-msg p, .heartai-msg ul { margin: 0 0 .45rem; }
.heartai-msg > :last-child { margin-bottom: 0; }
.heartai-msg ul { padding-left: 1.2rem; }
.heartai-you { align-self: flex-end; max-width: 85%; background: var(--link); color: var(--on-link); }
.heartai-ai { align-self: flex-start; max-width: 100%; background: var(--tint); }
.heartai-sources { font-size: .82rem; color: var(--muted); }
.heartai-error { color: var(--accent); }
.heartai-typing { display: inline-flex; gap: .3rem; }
.heartai-typing span { width: .45rem; height: .45rem; border-radius: 50%; background: var(--muted); animation: heartai-dot 1s infinite ease-in-out; }
.heartai-typing span:nth-child(2) { animation-delay: .15s; }
.heartai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes heartai-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.heartai-prompts { display: none; flex-wrap: wrap; gap: .4rem; }
.heartai-fresh .heartai-prompts { display: flex; }
.heartai-prompts button {
  border: 1px solid var(--line); background: var(--tint); color: var(--ink); border-radius: 999px;
  padding: .3rem .7rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.heartai-prompts button:hover { border-color: var(--link); color: var(--link); }
.heartai-form { display: flex; gap: .5rem; align-items: flex-end; }
.heartai-form textarea {
  flex: 1; width: 100%; resize: none; min-height: 2.75rem; max-height: 8rem; padding: .55rem .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 16px;
}
.heartai-form textarea:focus { outline: 2px solid var(--link); outline-offset: 0; }
.heartai-send {
  height: 2.75rem; padding: 0 1rem; border: 0; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  color: #fff; background: linear-gradient(135deg, var(--heartai-from, #e3103c), var(--heartai-to, #d24f00));
}
.heartai-send:disabled { opacity: .5; cursor: wait; }
.heartai-note { margin: 0; font-size: .75rem; color: var(--muted); }
@media (max-width: 40rem) {
  .ask-fab { width: 3.1rem; padding: 0; justify-content: center; }
  .ask-fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .heartai { right: .5rem; left: .5rem; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .ask-fab { transition: none; animation: none; }
  .heartai-typing span { animation: none; opacity: .6; }
}
.heartai-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
/* The microphone inside the question box (homes.me's .chat-mic): red with a spreading ring while it listens. */
.heartai-input { position: relative; flex: 1; display: flex; }
.heartai-input textarea { padding-right: 2.6rem; }
.heartai-mic {
  position: absolute; right: .3rem; bottom: .3rem; display: grid; place-items: center; width: 2.2rem; height: 2.2rem;
  padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted, #888); cursor: pointer;
}
.heartai-mic[hidden] { display: none; }
.heartai-mic:hover { color: var(--ink, #222); background: var(--tint, #eee); }
.heartai-mic[aria-pressed="true"] { background: #d92d20; color: #fff; animation: heartai-mic 1.4s ease-out infinite; }
@keyframes heartai-mic { 0% { box-shadow: 0 0 0 0 rgba(217, 45, 32, .5); } 100% { box-shadow: 0 0 0 12px rgba(217, 45, 32, 0); } }
@media (prefers-reduced-motion: reduce) { .heartai-mic[aria-pressed="true"] { animation: none; } }
/* The microphone inside a site's search box (a form marked data-heartai-voice): over the field's right end. */
form.heartai-voice { position: relative; }
form.heartai-voice input[type="search"], form.heartai-voice input[type="text"], form.heartai-voice textarea { padding-right: 2.5rem; }
.heartai-search-mic {
  position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
  width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted, #888); cursor: pointer;
}
.heartai-search-mic[hidden] { display: none; }
.heartai-search-mic:hover { color: var(--ink, #222); background: var(--tint, #eee); }
.heartai-search-mic[aria-pressed="true"] { background: #d92d20; color: #fff; animation: heartai-mic 1.4s ease-out infinite; }
@media (prefers-reduced-motion: reduce) { .heartai-search-mic[aria-pressed="true"] { animation: none; } }
