/* The book's chat drawer. Colours come from brand-tokens.css, so day and night themes both work.
   Docked bottom-right on larger screens (the book stays usable); full screen on phones. */
.tool.ask svg{fill:none;stroke:currentColor;stroke-width:1.7;stroke-linejoin:round}
.chat{position:fixed;right:max(12px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom));z-index:40;width:min(400px,calc(100vw - 24px));height:min(600px,calc(100vh - 90px));display:flex;flex-direction:column;background:var(--surface);color:var(--text);border:2px solid var(--text);border-radius:14px 18px 12px 20px/18px 12px 20px 14px;box-shadow:6px 6px 0 var(--yellow);font:400 15.5px/1.5 var(--body);overflow:hidden}
.chat[hidden]{display:none}
.chat-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px 10px 16px;background:var(--ink);color:#FBF4DD;border-bottom:3px solid var(--yellow)}
.chat-head h2{margin:0;font:600 17px/1.2 var(--display)}
.chat .x{min-width:40px;min-height:40px;border:0;background:transparent;color:inherit;font-size:24px;line-height:1;cursor:pointer;border-radius:8px}
.chat .log{flex:1;overflow-y:auto;padding:14px 14px 6px;display:flex;flex-direction:column;gap:10px;overscroll-behavior:contain}
.chat .msg{max-width:88%;padding:.55em .8em;border-radius:12px;overflow-wrap:anywhere}
.chat .msg p{margin:0 0 .45em}.chat .msg p:last-child{margin:0}
.chat .msg ul{margin:.2em 0 .45em;padding-left:1.15em}
.chat .msg a{color:inherit;text-decoration-color:var(--honey);text-underline-offset:.18em}
.chat .me{align-self:flex-end;background:var(--ink);color:#FBF4DD;border-bottom-right-radius:4px}
.chat .bot{align-self:flex-start;background:var(--wax);color:var(--ink);border:1.5px solid rgba(22,22,22,.18);border-bottom-left-radius:4px}
.chat .typing::after{content:"…";display:inline-block;animation:chat-dots 1s steps(3,end) infinite;width:1.2em;overflow:hidden;vertical-align:bottom}
@keyframes chat-dots{from{width:0}to{width:1.2em}}
@media (prefers-reduced-motion:reduce){.chat .typing::after{animation:none}}
.chat .handoff{display:flex;flex-wrap:wrap;gap:8px;margin:0}
.chat .btn-mini,.chat .chip{display:inline-flex;align-items:center;min-height:38px;padding:6px 12px;border:1.5px solid var(--text);border-radius:999px;background:transparent;color:var(--text);font:400 14px/1.25 var(--body);text-decoration:none;cursor:pointer;text-align:left}
.chat .btn-mini:first-child{background:var(--ink);color:var(--yellow);border-color:var(--ink)}
.chat .chips{display:flex;flex-wrap:wrap;gap:6px;padding:4px 14px 8px}
.chat-status{min-height:0;margin:0;padding:0 14px;font-size:13px;color:var(--muted)}
.chat .ask-form{display:flex;gap:8px;align-items:flex-end;padding:8px 12px;border-top:1.5px solid var(--line)}
.chat textarea{flex:1;resize:none;min-height:44px;max-height:120px;padding:9px 11px;border:1.5px solid var(--text);border-radius:10px;background:var(--bg);color:var(--text);font:inherit}
.chat .send{min-height:44px;padding:0 16px;border:0;border-radius:10px;background:var(--yellow);color:var(--ink);font:600 15px/1 var(--body);cursor:pointer}
.chat .send:disabled{opacity:.55;cursor:wait}
.chat .hp{position:absolute;left:-9999px;width:1px;height:1px}
.chat-foot{margin:0;padding:4px 14px 10px;font-size:13px;color:var(--muted)}
.chat-foot a,.chat-foot .quiet{color:inherit;font:inherit;background:none;border:0;padding:0;text-decoration:underline;text-underline-offset:.15em;cursor:pointer}
.chat :focus-visible{outline:3px solid var(--honey);outline-offset:2px}
@media (max-width:640px){
  .chat{inset:0;width:auto;height:auto;border:0;border-radius:0;box-shadow:none;padding-bottom:env(safe-area-inset-bottom)}
  html.chat-open,html.chat-open body{overflow:hidden}
}
@media print{.chat,.tool.ask{display:none!important}}
.chat :focus-visible{outline-color:var(--honey-deep)}
.chat-head :focus-visible{outline-color:var(--yellow)}
