/* Standalone chatbot styles for pages that don't load styles/styles.css
   (journal/, blog/). Variables are scoped to the widget so they can't
   affect the host page. */
.cb-toggle, .cb-panel {
    --bg-primary: #FFFFFF; --bg-secondary: #F3F4F3;
    --text-primary: #0E1726; --text-secondary: #5B6472;
    --accent-gold: #0E1726; --accent-gold-light: rgba(37,82,208,0.08);
    --glass-border: rgba(14,23,38,0.14);
    --radius-lg: 12px; --radius-md: 8px;
    --shadow-md: 0 8px 24px rgba(14,23,38,.10); --shadow-hover: 0 18px 48px rgba(14,23,38,.14);
    --ease: cubic-bezier(.2,.8,.2,1); --transition: all .25s cubic-bezier(.2,.8,.2,1);
    font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
}
.cb-panel *, .cb-toggle * { box-sizing: border-box; }
.cb-panel p { margin: 0; }
.cb-panel a { text-decoration: none; }
/* ═══════════════════════════════════════════════════════
   Chatbot - Ask about Shanjai
   A floating, rule-based FAQ widget present site-wide. No
   external API, no network request - pure client-side keyword
   matching against a fixed knowledge base built from real site
   content, disclosed as such in the panel itself.
   ═══════════════════════════════════════════════════════ */
.cb-toggle { position: fixed; bottom: 2rem; left: 2rem; width: 56px; height: 56px; border-radius: 50%; background: var(--accent-gold); color: var(--bg-primary); border: none; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; cursor: pointer; box-shadow: var(--shadow-md); z-index: 950; transition: var(--transition); }
.cb-toggle:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.cb-toggle:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 3px; }

.cb-panel { position: fixed; bottom: calc(2rem + 68px); left: 2rem; width: 360px; max-width: calc(100vw - 2.5rem); height: 620px; max-height: calc(100vh - 8rem); background: var(--bg-primary); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(10,20,40,0.22); display: flex; flex-direction: column; z-index: 951; opacity: 0; transform: translateY(16px) scale(0.98); pointer-events: none; transition: opacity 0.25s var(--ease), transform 0.25s var(--ease); overflow: hidden; }

/* On Playground pages the sidebar already owns the left 240px column
   (desktop only - it's an off-screen drawer on mobile) - shift the
   widget clear of it there instead of sitting on top of the nav tree. */
@media (min-width: 1025px) {
    body.pg-page .cb-toggle { left: calc(240px + 1.5rem); }
    body.pg-page .cb-panel { left: calc(240px + 1.5rem); }
}
.cb-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.cb-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--glass-border); background: var(--bg-secondary); flex-shrink: 0; }
.cb-header-info { display: flex; align-items: center; gap: 0.75rem; }
.cb-avatar { display: flex; color: var(--accent-gold); flex-shrink: 0; }
.cb-toggle-icon { display: flex; }
.cb-header-info strong { display: block; font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }
.cb-sub { display: block; font-size: 0.66rem; color: var(--text-secondary); margin-top: 0.15rem; }
.cb-close { background: none; border: none; color: var(--text-secondary); font-size: 1rem; cursor: pointer; padding: 0.3rem; line-height: 1; }
.cb-close:hover { color: var(--accent-gold); }

.cb-messages { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.85rem; }
.cb-msg { max-width: 88%; }
.cb-msg p { margin: 0; font-size: 0.83rem; line-height: 1.55; }
.cb-msg--bot { align-self: flex-start; background: var(--bg-secondary); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 0.7rem 0.9rem; color: var(--text-primary); }
.cb-msg--user { align-self: flex-end; background: var(--accent-gold); border-radius: var(--radius-lg); padding: 0.7rem 0.9rem; }
.cb-msg--user p { color: var(--bg-primary); }
.cb-msg-links { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.65rem; }
.cb-msg-link { display: flex; align-items: center; justify-content: space-between; font-size: 0.76rem; font-weight: 700; color: var(--accent-gold); background: var(--bg-primary); border: 1px solid rgba(20,33,61,0.2); border-radius: var(--radius-md); padding: 0.45rem 0.7rem; transition: var(--transition); }
.cb-msg-link:hover { background: var(--accent-gold-light); }
.cb-msg-link i { font-size: 0.7rem; }

.cb-typing { align-self: flex-start; background: var(--bg-secondary); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 0.85rem 1rem; display: flex; gap: 0.3rem; }
.cb-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary); opacity: 0.5; animation: cbTypingBounce 1.2s infinite ease-in-out; }
.cb-typing span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cbTypingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.cb-quick { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1.25rem 1rem; flex-shrink: 0; }
.cb-quick-btn { font-family: inherit; font-size: 0.72rem; font-weight: 600; color: var(--text-primary); background: var(--bg-secondary); border: 1px solid var(--glass-border); border-radius: 100px; padding: 0.4rem 0.8rem; cursor: pointer; transition: var(--transition); }
.cb-quick-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); }
.cb-quick-btn:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 2px; }

.cb-input-row { display: flex; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--glass-border); flex-shrink: 0; }
.cb-input-row input { flex: 1; min-width: 0; font-family: inherit; font-size: 0.83rem; padding: 0.65rem 0.9rem; border: 1px solid var(--glass-border); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); }
.cb-input-row input:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 1px; }
.cb-input-row button { width: 40px; height: 40px; border-radius: var(--radius-md); border: none; background: var(--accent-gold); color: var(--bg-primary); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: var(--transition); }
.cb-input-row button:hover { opacity: 0.88; }

@media (max-width: 480px) {
    .cb-toggle, body.pg-page .cb-toggle { left: 1.25rem; bottom: calc(1.25rem + 66px); width: 52px; height: 52px; }
    .cb-panel, body.pg-page .cb-panel { left: 0.75rem; right: 0.75rem; bottom: calc(5rem + 66px); width: auto; max-width: none; height: min(72vh, 560px); }
}

/* Screen-reader-only label used inside the widget */
.cb-panel .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
