/* Kai: his small window on every screen and his tab in HQ, taken from the old TCY (map/app/kai.css, artboards KaiSmall and KaiHQ). */
:root { --kai: #b197fc; --kai-edge: #4b3d7a; --kai-card: #1c2028; --kai-me: #1d3a55; --kai-him: #262b35; --kai-line: #2b3039; --kai-btn: #3a404b; --kai-faint: #9aa1ad; --kai-wait: #7a5a2b; }

/* ---------- the small window ---------- */
.kai-win { position: fixed; z-index: 47; right: 120px; bottom: 32px; width: 420px; height: min(560px, calc(100vh - 64px)); display: flex; flex-direction: column;
  background: var(--kai-card); border: 1px solid var(--kai-edge); border-radius: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.5); color: #e9ebef; animation: pop .18s ease-out; }
.kai-head { flex: none; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 10px 12px; border-bottom: 1px solid var(--kai-line); }
.kai-head > b { font: 600 15px var(--head); }
.kai-mark { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--kai); stroke-width: 1.7; stroke-linejoin: round; }
.kai-head-btns { margin-left: auto; display: flex; gap: 4px; flex: none; }
.kai-head-btns button { width: 36px; height: 36px; border-radius: 8px; background: none; border: 0; color: #c9ced6; font-size: 18px; cursor: pointer; }
.kai-head-btns button:hover { color: #fff; background: rgba(226,232,242,.06); }

/* the talk: the one part that scrolls, as every chat does; it opens at its newest */
.kai-talk { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.kai-talk > :first-child { margin-top: auto; }
.kai-me { align-self: flex-end; max-width: 86%; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.kai-me .b, .kai-him .b { margin: 0; padding: 9px 12px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.kai-me .b { background: var(--kai-me); border-radius: 12px 12px 4px 12px; white-space: pre-wrap; }
.kai-him { align-self: flex-start; max-width: 90%; display: flex; flex-direction: column; gap: 3px; }
.kai-him .b { background: var(--kai-him); border-radius: 12px 12px 12px 4px; }
.kai-him.alert .b { border: 1px solid var(--kai-wait); }
.kai-him.ask .b { border: 1px solid var(--kai-edge); }
.kai-him.writing .b::after { content: '▍'; color: var(--kai); margin-left: 1px; animation: blink 1s steps(2) infinite; }
.kai-from { font-size: 11.5px; color: var(--kai-faint); }
.kai-from button { background: none; border: 0; padding: 0 0 0 4px; color: var(--kai); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.kai-note, .kai-day { align-self: center; max-width: 92%; font-size: 12px; color: var(--kai-faint); text-align: center; }
.kai-day { padding: 4px 0; }
.kai-onit { font-style: italic; }
.kai-ul { margin: 2px 0; padding-left: 18px; } .kai-ul li { margin: 1px 0; }
@keyframes blink { 50% { opacity: 0; } }

.kai-foot { flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--kai-line); background: var(--kai-card); }
.kai-foot textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 160px; resize: none; margin: 0; background: #101216; border: 1px solid var(--kai-btn); border-radius: 10px;
  color: #e9ebef; font: 400 14px var(--font); padding: 11px 11px; }
.kai-btn { width: 44px; height: 44px; flex: none; border-radius: 10px; background: none; border: 1px solid var(--kai-btn); color: #c9ced6; display: grid; place-items: center; cursor: pointer; padding: 0; }
.kai-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kai-btn.go { background: #e8ebf0; border: 0; color: #121418; }
.kai-btn:disabled { opacity: .5; }

/* ---------- HQ › Kai: the whole talk, the day's note, his open questions ---------- */
/* The computer: the talk on the left with its box under it, his questions and the day on the right (the drawing KaiHQ).
   The phone: one page that grows: the day, the talk, his questions, and the box that stays at the bottom. */
.hq-kai { display: grid; gap: 0 14px; grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas: "main heads" "main wait" "main today" "foot today"; grid-template-rows: auto auto minmax(0, 1fr) auto; flex: 1; min-height: 0; }
.kq-main { grid-area: main; min-width: 0; min-height: 0; border: 1px solid var(--kai-edge); border-bottom: 0; border-radius: 12px 12px 0 0; display: flex; flex-direction: column; background: var(--kai-card); }
.kq-foot { grid-area: foot; border: 1px solid var(--kai-edge); border-top-color: var(--kai-line); border-radius: 0 0 12px 12px; }
.kq-wait { grid-area: wait; margin-bottom: 10px; }
.kq-today { grid-area: today; align-self: start; }
.kq-main .kai-me .b, .kq-main .kai-him .b { font-size: 14.5px; }
.kq-main .kai-me { max-width: 72%; } .kq-main .kai-him { max-width: 76%; }
.kq-card { border: 1px solid var(--kai-line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--kai-card); color: #e9ebef; min-width: 0; }
.kq-card.wait { border-color: var(--kai-wait); gap: 10px; }
.kq-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.kq-cap { font: 600 12px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--kai-faint); }
.kq-cap.c-wait { color: #ffc078; } .kq-cap.c-now { color: var(--kai); }
.kq-sub { font-size: 13px; color: var(--kai-faint); }
.kq-note { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; font-size: 13.5px; line-height: 1.4; }
.kq-note .kq-t { color: var(--kai-faint); font-variant-numeric: tabular-nums; }
.kq-note .kq-w { grid-column: 1 / -1; }
.kw-item { display: flex; flex-direction: column; gap: 8px; }
.kw-t { font-size: 14.5px; line-height: 1.45; } .kw-t i { font-style: normal; font-size: 12.5px; color: var(--kai-faint); margin-left: 4px; }
.kp-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kp-a { min-height: 36px; border-radius: 8px; padding: 5px 12px; font: 600 13px var(--font); cursor: pointer; background: none; border: 1px solid var(--kai-btn); color: #c9ced6; }
.kp-a.rec { background: #e8ebf0; border-color: #e8ebf0; color: #121418; }
.kp-a[aria-pressed="true"] { border-color: var(--kai); color: #fff; }
.kp-a.rec[aria-pressed="true"] { color: #121418; box-shadow: 0 0 0 2px var(--kai); }
.kp-a:disabled { opacity: .5; cursor: default; }
.kw-more { display: flex; flex-direction: column; gap: 6px; }
.kw-more label { font-size: 12px; color: var(--kai-faint); }
.kw-more textarea, .kw-more input { width: 100%; margin: 0; background: #101216; border: 1px solid var(--kai-btn); border-radius: 8px; color: #e9ebef; font: 14px var(--font); padding: 8px 10px; }
.kw-more textarea { min-height: 64px; resize: vertical; }
.kw-more input { height: 40px; color-scheme: dark; }
.kw-row { display: flex; gap: 8px; align-items: center; } .kw-row input { flex: 1; min-width: 0; }
.kw-err { margin: 0; font-size: 12.5px; color: #ffc078; }
.kq-quiet { font-size: 12.5px; padding: 4px 10px; min-height: 32px; color: var(--kai-faint); border-color: var(--kai-btn); }

@media (min-width: 761px) {
  #hq .bw-body { display: flex; overflow: hidden; }
  .kq-today { max-height: 100%; overflow-y: auto; }   /* (the computer only: a very long day's note) */
}
@media (max-width: 760px) {
  .kai-win { left: 8px; right: 8px; width: auto; top: 45%; bottom: calc(var(--dock-space) + 8px); height: auto; }
  body.kb-open .kai-win { top: 8px; bottom: calc(var(--kb, 0px) + 8px); }   /* the keyboard is up: the window sits on it */
  .kai-from button { position: relative; }
  .kai-from button::after { content: ''; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: 44px; transform: translate(-50%, -50%); }
  .kai-foot { gap: 6px; padding: 8px; }
  .kai-head-btns button { width: 44px; height: 44px; }
  .kp-a { min-height: 44px; flex: 1 1 auto; }
  .kq-quiet { min-height: 44px; }
  .kw-more input { height: 44px; }
  .hq-kai { display: flex; flex-direction: column; gap: 10px; }
  .hq-heads { order: 0; } .kq-today { order: 1; } .kq-main { order: 2; } .kq-wait { order: 3; margin: 0; } .kq-foot { order: 4; }
  .kq-main { border: 0; background: none; border-radius: 0; }
  .kq-main .kai-talk { overflow: visible; flex: none; padding: 4px 0; }
  #hqBody { padding-bottom: 0; }   /* (a sticky box sits inside its scroller's padding: none here, so it never covers the last card) */
  .kq-foot { position: sticky; bottom: 0; margin: 0 -14px; border: 0; border-top: 1px solid var(--kai-line); border-radius: 0; background: var(--panel); }
  .kq-card { padding: 9px 12px; }
}
