/* Benben, the site's AI (sections/ai.js): a round button at the bottom right of every page, and its panel,
   a card at the bottom right on wide screens and a sheet from the bottom on phones. Its own tokens and
   base rules, so it looks the same over every page, whose page tokens differ. */
.bx,.bx-fab{
 --bg:#fff;--fill:#f5f5f7;--pink:#fbe9ef;
 --ink:#1d1d1f;--ink-2:#424245;--gray:#6e6e73;--gray-2:#86868b;
 --line:#e5e5ea;--line-2:#d2d2d7;
 --accent:#bc486a;
 --font:-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue","PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans SC",sans-serif;
}
:where(.bx) *,:where(.bx) *::before,:where(.bx) *::after{box-sizing:border-box}
:where(.bx) a{color:inherit;text-decoration:none}
:where(.bx) button,:where(.bx) textarea{font:inherit;color:inherit}
:where(.bx) :focus-visible{outline:2px solid var(--accent);outline-offset:2px}
:where(.bx) [hidden]{display:none!important}
.bx-lock,.bx-lock body{overflow:hidden}

/* The button: Benito on white, over everything on the page but its dialogs. */
.bx-fab{position:fixed;right:max(16px,calc(env(safe-area-inset-right) + 12px));bottom:max(16px,calc(env(safe-area-inset-bottom) + 12px));z-index:30;display:grid;place-items:center;width:52px;height:52px;margin:0;padding:0;border:1px solid #1d1d1f14;border-radius:50%;background:#fffffff2;-webkit-backdrop-filter:blur(12px) saturate(1.2);backdrop-filter:blur(12px) saturate(1.2);box-shadow:0 10px 28px -12px #1d1d1f73,0 2px 6px -2px #1d1d1f26;cursor:pointer;--dog-ink:#1d1d1f;--dog-tongue:#e8879f;font:400 12px/1.5 var(--font);-webkit-tap-highlight-color:transparent;transition:transform .2s,box-shadow .2s}
.bx-fab .bn-dog{display:block;width:32px;height:32px;transition:transform .3s cubic-bezier(.3,1.6,.5,1)}
.bx-fab:hover{box-shadow:0 14px 32px -12px #1d1d1f80,0 2px 6px -2px #1d1d1f26}
.bx-fab:hover .bn-dog{transform:rotate(-10deg) scale(1.06)}
.bx-fab:active{transform:scale(.94)}
.bx-fab:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
/* An answer that came while the panel was closed. */
.bx-fab.bx-dot::before{content:"";position:absolute;top:3px;right:3px;width:10px;height:10px;border:2px solid #fff;border-radius:50%;background:var(--accent)}
@media (hover:hover){
 .bx-fab::after{content:attr(aria-label);position:absolute;right:calc(100% + 10px);top:50%;padding:6px 10px;border:1px solid #1d1d1f12;border-radius:10px;background:#f0f0f2d9;-webkit-backdrop-filter:blur(10px) saturate(1.2);backdrop-filter:blur(10px) saturate(1.2);color:var(--ink-2);white-space:nowrap;box-shadow:0 8px 20px -14px #1d1d1f66;opacity:0;transform:translate(3px,-50%);pointer-events:none;transition:opacity .15s,transform .15s}
 .bx-fab:hover::after,.bx-fab:focus-visible::after{opacity:1;transform:translate(0,-50%)}
}
/* Not during the homepage's opening film, and not under the open panel; one in the reader over the
   panel stays, to come back to it. */
.opening .bx-fab,.bx-lock body>.bx-fab{visibility:hidden}
/* In a song on 柯南, clear of that dialog's own scrollbar. */
#detail>.bx-fab{right:calc(max(16px,calc(env(safe-area-inset-right) + 12px)) + var(--sbw,0px))}
/* In the reader, the text's last lines scroll clear of it. */
.reader:has(>.bx-fab) .rd-body{padding-bottom:calc(84px + env(safe-area-inset-bottom))}

/* The panel. */
.bx{position:fixed;inset:auto 16px 16px auto;width:min(420px,100vw - 32px);max-width:none;height:min(720px,100dvh - 32px);max-height:none;margin:0;padding:0;border:0;border-radius:16px;background:var(--bg);color:var(--ink);box-shadow:0 30px 80px -20px #1d1d1f66,0 0 0 1px #1d1d1f0f;overflow:hidden;font:400 15px/1.7 var(--font);line-break:strict;-webkit-font-smoothing:antialiased}
.bx[open]{display:flex;flex-direction:column;animation:bx-in .22s ease-out}
.bx::backdrop{background:#1d1d1f33;animation:bx-fade .22s ease-out}
.bx-head{flex:none;display:flex;align-items:center;gap:10px;padding:14px 12px 12px 16px;border-bottom:1px solid var(--line)}
.bx-head>.bn-dog{flex:none;width:36px;height:36px;--dog-ink:var(--ink)}
.bx-head>div{flex:1;min-width:0}
.bx-head h2{margin:0;font-size:16px;font-weight:600;line-height:1.3}
#bx-t:focus{outline:none}
.bx-head p{margin:1px 0 0;color:var(--gray);font-size:12px;line-height:1.4}
.bx-icon{flex:none;display:grid;place-items:center;width:36px;height:36px;padding:0;border:0;border-radius:50%;background:none;color:var(--ink-2);cursor:pointer;transition:background-color .15s,color .15s}
.bx-icon:hover{background:var(--fill);color:var(--accent)}
.bx-icon svg{width:16px;height:16px}
.bx-x{background:var(--fill)}
.bx-x svg{width:14px;height:14px}
.bx-x:hover{background:var(--pink)}

.bx-log{position:relative;flex:1;min-height:0;display:flex;flex-direction:column;gap:14px;padding:16px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.bx-log p{margin:0}
.bx-me{align-self:flex-end;max-width:85%;padding:8px 14px;border-radius:16px 16px 4px 16px;background:var(--fill);white-space:pre-wrap;overflow-wrap:anywhere}
.bx-bot{max-width:100%;overflow-wrap:anywhere}
.bx-bot p+p,.bx-bot p+ul,.bx-bot ul+p{margin-top:10px}
.bx-bot ul{margin:0;padding:0 0 0 1.2em}
.bx-bot li+li{margin-top:4px}
/* An entry the answer draws on: a number in the text, and the list under it. */
.bx-n{display:inline-grid;place-items:center;min-width:18px;height:18px;margin:0 1px 0 2px;padding:0 4px;border:0;border-radius:9px;background:var(--pink);color:var(--accent);font-size:11px;font-weight:600;line-height:1;vertical-align:2px;cursor:pointer;transition:background-color .15s,color .15s}
.bx-n:hover{background:var(--accent);color:#fff}
.bx-refs{display:flex;flex-direction:column;align-items:flex-start;gap:6px;margin-top:12px}
.bx-ref{display:inline-flex;align-items:baseline;gap:6px;max-width:100%;padding:5px 12px 5px 6px;border:1px solid var(--line-2);border-radius:14px;background:none;color:var(--ink-2);font-size:13px;line-height:1.5;text-align:left;cursor:pointer;transition:border-color .15s,color .15s}
.bx-ref:hover{border-color:var(--accent);color:var(--accent)}
.bx-i{flex:none;display:inline-grid;place-items:center;min-width:18px;height:18px;border-radius:9px;background:var(--pink);color:var(--accent);font-size:11px;font-weight:600;line-height:1;transform:translateY(-1px)}
.bx-k{flex:none;color:var(--gray);font-size:12px}
.bx-ref>span:last-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.bx-hi{color:var(--ink-2)}
.bx-sug{display:flex;flex-direction:column;align-items:flex-start;gap:8px;margin-top:14px}
.bx-s{padding:7px 14px;border:1px solid var(--line-2);border-radius:18px;background:none;color:var(--ink-2);font-size:14px;line-height:1.5;text-align:left;cursor:pointer;transition:border-color .15s,color .15s}
.bx-s:hover{border-color:var(--accent);color:var(--accent)}
.bx-wait{display:flex;align-items:center;gap:8px;color:var(--gray);font-size:13px}
.bx-wait .bn-dog{flex:none;width:26px;height:26px;--dog-ink:var(--ink);animation:bx-think .9s ease-in-out infinite alternate;transform-origin:50% 70%}
.bx-err{color:var(--accent);font-size:14px}

.bx-form{flex:none;margin:0;padding:10px 12px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line)}
.bx-at{display:flex;align-items:center;gap:6px;margin:0 0 8px;padding:0 4px;color:var(--gray);font-size:12px;line-height:1.5}
.bx-at>span{flex:none}
.bx-at b{min-width:0;overflow:hidden;color:var(--ink-2);font-weight:500;text-overflow:ellipsis;white-space:nowrap}
.bx-at button{flex:none;display:grid;place-items:center;width:22px;height:22px;margin-left:-2px;padding:0;border:0;border-radius:50%;background:none;color:var(--gray-2);cursor:pointer}
.bx-at button:hover{background:var(--fill);color:var(--accent)}
.bx-at svg{width:9px;height:9px}
.bx-field{display:flex;align-items:flex-end;gap:8px;padding:6px 6px 6px 14px;border:1px solid var(--line-2);border-radius:22px;background:var(--bg);transition:border-color .15s}
.bx-field:focus-within{border-color:var(--accent)}
.bx-field textarea{flex:1;min-width:0;height:28px;max-height:120px;margin:0 0 2px;padding:3px 0;border:0;background:none;font-size:16px;line-height:1.4;resize:none;outline:none}
.bx-field textarea::placeholder{color:var(--gray-2)}
.bx-send{flex:none;display:grid;place-items:center;width:32px;height:32px;padding:0;border:0;border-radius:50%;background:var(--accent);color:#fff;cursor:pointer;transition:background-color .15s}
.bx-send:disabled{background:var(--line-2);cursor:default}
.bx-send svg{width:16px;height:16px}

@keyframes bx-in{from{opacity:0;transform:translateY(12px) scale(.98)}}
@keyframes bx-fade{from{opacity:0}}
@keyframes bx-up{from{transform:translateY(100%)}}
@keyframes bx-think{from{transform:rotate(-9deg)}to{transform:rotate(9deg)}}

@media (max-width:760px){
 .bx-fab{width:48px;height:48px}
 .bx-fab .bn-dog{width:30px;height:30px}
 /* All of what is visible (sections/ai.js sets --vt and --vh from the visual viewport), keyboard or not. */
 .bx{inset:var(--vt,0px) 0 auto 0;width:100%;height:var(--vh,100dvh);border-radius:0;box-shadow:none}
 .bx[open]{animation:bx-up .26s cubic-bezier(.2,.8,.2,1)}
 .bx-head{padding-top:calc(10px + env(safe-area-inset-top));padding-bottom:10px}
 /* With the keyboard up, the head and the box take less room, for the conversation. */
 .bx-kb .bx-head{padding-top:6px;padding-bottom:6px}
 .bx-kb .bx-head p{display:none}
 .bx-kb .bx-head>.bn-dog{width:28px;height:28px}
 .bx-kb .bx-form{padding-bottom:8px}
 .bx-kb .bx-at{margin-bottom:6px}
 .bx-log{padding:14px 16px}
 .reader:has(>.bx-fab) .rd-body{padding-bottom:calc(76px + env(safe-area-inset-bottom))}
}
@media (prefers-reduced-motion:reduce){
 .bx,.bx::backdrop,.bx-wait .bn-dog{animation:none!important}
 .bx-fab,.bx-fab .bn-dog{transition:none}
}
