/* One assistant surface for the site guide and the quote reader. */
html.qw-ui #aiFloatContainer { position: fixed; bottom: 28px; left: 28px; z-index: 90; font-family: var(--qw-font-ui); }
html.qw-ui #aiFloatBtn {
    display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; padding: 12px;
    border: 1px solid var(--qw-line); border-radius: var(--qw-radius-circle); background: var(--qw-menu-glass);
    color: var(--qw-accent); box-shadow: var(--qw-shadow-float); cursor: pointer;
    backdrop-filter: blur(var(--qw-menu-blur)); -webkit-backdrop-filter: blur(var(--qw-menu-blur));
}
html.qw-ui #aiFloatBtn:hover { transform: translateY(-3px); }
html.qw-ui #aiFloatBtn.active { background: var(--qw-accent-soft); }
.ai-reader-logo { width: 32px; height: 32px; object-fit: contain; }
.ai-reader-tab-label { display: flex; flex-direction: column; align-items: center; gap: 0; font-size: 14px; line-height: 1.15; writing-mode: horizontal-tb; }
.ai-reader-tab-label > span { display: block; }
body:not(.qw-detail-page) .ai-reader-tab-label { display: none; }
html.qw-ui #aiChatWindow {
    position: absolute; bottom: 76px; left: 0; width: min(420px, calc(100vw - 32px));
    height: min(680px, calc(100dvh - var(--qw-header-height) - 116px));
    display: flex; flex-direction: column; min-height: 0; overflow: hidden;
    border: 1px solid var(--qw-line); border-radius: var(--qw-radius-panel);
    background: var(--qw-menu-glass); color: var(--qw-ink); box-shadow: var(--qw-shadow-float);
    backdrop-filter: blur(var(--qw-menu-blur)); -webkit-backdrop-filter: blur(var(--qw-menu-blur));
    opacity: 0; visibility: hidden; transform: translateY(12px);
    transition: transform 280ms var(--qw-ease), opacity 180ms, visibility 180ms;
}
html.qw-ui #aiChatWindow.show { opacity: 1; visibility: visible; transform: translateY(0); }
html.qw-ui #aiChatWindow :is(.ai-chat-header,.ai-quick-questions,.ai-chat-input-area) { padding: 14px 16px; background: transparent; }
html.qw-ui #aiChatWindow .ai-chat-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-shrink: 0; border-bottom: 1px solid var(--qw-line); }
.ai-chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ai-chat-title h3 { margin: 0; font-size: 1.1rem; }
.ai-chat-title span { font-size: .8rem; color: var(--qw-muted); }
.ai-status-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--qw-accent); }
.ai-reader-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
html.qw-ui #aiChatWindow :is(.ai-chat-close,.ai-chat-clear) { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--qw-radius-control); background: transparent; color: var(--qw-muted); cursor: pointer; }
html.qw-ui #aiChatWindow :is(.ai-chat-close,.ai-chat-clear):hover { background: var(--qw-accent-soft); color: var(--qw-accent); }
.ai-reader-context { padding: 12px 16px 0; font-size: .8rem; color: var(--qw-muted); overflow-wrap: anywhere; }
html.qw-ui #aiChatWindow .ai-quick-questions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
html.qw-ui #aiChatWindow .ai-quick-btn { padding: 6px 10px; border: 1px solid var(--qw-line); border-radius: var(--qw-radius-control); background: var(--qw-surface); color: var(--qw-accent); cursor: pointer; font-size: .85rem; }
html.qw-ui #aiChatWindow .ai-quick-btn:hover { background: var(--qw-accent-soft); }
html.qw-ui #aiChatWindow .ai-chat-messages { flex: 1 1 0; min-height: 80px; padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; overscroll-behavior: contain; background: transparent; scrollbar-width: thin; }
html.qw-ui #aiChatWindow .ai-welcome { margin: auto 0; padding: 16px 4px; }
.ai-welcome h4 { margin: 0 0 10px; font-size: 1.1rem; }
.ai-welcome p { margin: 0; font-size: .9rem; color: var(--qw-muted); }
.ai-guide-links { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 18px; }
.ai-guide-links a { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: var(--qw-radius-control); background: var(--qw-surface); color: var(--qw-accent); text-decoration: none; font-size: .9rem; }
.ai-guide-links a:hover { background: var(--qw-accent-soft); }
html.qw-ui #aiChatWindow .ai-message { max-width: 94%; padding: 12px 14px; border-radius: var(--qw-radius-control); line-height: 1.7; font-size: .9rem; overflow-wrap: anywhere; }
.ai-message.user { align-self: flex-end; background: var(--qw-accent); color: white; white-space: pre-wrap; }
.ai-message.assistant { align-self: flex-start; background: var(--qw-surface); border: 1px solid var(--qw-line); }
.ai-message.assistant :is(h1,h2,h3) { margin: 0 0 10px; font-size: 1rem; color: var(--qw-ink); }
.ai-message p { margin: 0 0 .7em; }
.ai-message p:last-child { margin-bottom: 0; }
.ai-message :is(ul,ol) { padding-left: 1.3rem; margin: .4em 0; }
.ai-message code { background: var(--qw-accent-soft); border-radius: 4px; padding: .1em .3em; }
html.qw-ui #aiChatWindow .ai-chat-input-area { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; flex-shrink: 0; border-top: 1px solid var(--qw-line); }
html.qw-ui #aiChatWindow .ai-chat-input { width: 100%; min-width: 0; flex: 1 1 100%; min-height: 48px; max-height: 100px; padding: 10px 12px; border: 1px solid var(--qw-line); border-radius: var(--qw-radius-control); background: var(--qw-surface); overflow-y: auto; resize: none; }
html.qw-ui #aiChatWindow .ai-chat-send { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: auto; border: 0; border-radius: var(--qw-radius-control); background: var(--qw-accent); color: white; cursor: pointer; }
html.qw-ui #aiChatWindow button:disabled { opacity: .5; cursor: default; }
.ai-reader-status { padding: 0 16px 10px; font-size: .8rem; color: var(--qw-muted); overflow-wrap: anywhere; }
.ai-reader-status:empty { display: none; }
html.qw-ui #aiChatWindow :is(.ai-chat-stop,.ai-reader-status button) { padding: 6px 12px; border: 1px solid var(--qw-line); border-radius: var(--qw-radius-control); background: var(--qw-surface); color: var(--qw-accent); cursor: pointer; }
html.qw-ui #aiChatWindow .ai-chat-stop[hidden] { display: none; }
.ai-typing { display: none; flex-shrink: 0; align-self: flex-start; gap: 4px; margin: 0 16px 12px; padding: 12px; }
.ai-typing.show { display: flex; }
.ai-typing span { width: 6px; height: 6px; background: var(--qw-accent); border-radius: 50%; animation: qw-ai-typing 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }
.ai-streaming-cursor { display: inline-block; width: 2px; height: 1em; margin-left: 2px; background: var(--qw-accent); vertical-align: -.15em; }
#aiDrawerHandle { display: none; }
@keyframes qw-ai-typing { 50% { opacity: .35; transform: translateY(-3px); } }
@media (max-width: 600px) { html.qw-ui #aiFloatContainer { left: 16px; bottom: calc(var(--qw-bottom-inset) + 16px); } }
@media (prefers-reduced-motion: reduce) { html.qw-ui #aiChatWindow { transition: none; } .ai-typing span { animation: none; } }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { html.qw-ui :is(#aiFloatBtn,#aiChatWindow) { background: var(--qw-surface); } }
