/* Johnny S. - floating voice assistant */
.jy-root { --jy-right: 20px; --jy-bottom: 20px; --jy-lift: 0px; position: fixed; right: var(--jy-right); bottom: calc(var(--jy-bottom) + var(--jy-lift)); z-index: 2147482500; font-family: 'Inter', system-ui, sans-serif; }
body.has-mini-player .jy-root { --jy-lift: 118px; }
@media (max-width: 720px) { body.has-mini-player .jy-root { --jy-lift: 150px; } }
body.reader-page .jy-root { --jy-bottom: 90px; }

/* ---- floating button ---- */
.jy-fab { position: relative; width: 64px; height: 64px; border: 0; border-radius: 50%; padding: 0; cursor: pointer; background: transparent; touch-action: none; display: block; margin-left: auto; }
.jy-fab-face { position: absolute; inset: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff;
    background: #000; box-shadow: 0 10px 28px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.12); transition: transform .2s; }
.jy-fab-face b { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.jy-fab-face i { position: absolute; right: 2px; bottom: 2px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .72rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.jy-fab:hover .jy-fab-face { transform: scale(1.07); }
.jy-fab-ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(0, 139, 116, .55); animation: jyBreath 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes jyBreath { 0%, 100% { transform: scale(.96); opacity: .8; } 50% { transform: scale(1.12); opacity: .15; } }
.jy-bars { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: 3px; border-radius: 50%; background: rgba(0, 0, 0, .7); }
.jy-bars i { width: 4px; height: 10px; border-radius: 2px; background: #fff; animation: jyBar .9s ease-in-out infinite; }
.jy-bars i:nth-child(2) { animation-delay: .15s; } .jy-bars i:nth-child(3) { animation-delay: .3s; } .jy-bars i:nth-child(4) { animation-delay: .45s; }
@keyframes jyBar { 0%, 100% { height: 8px; } 50% { height: 26px; } }
.jy-root[data-mode="speaking"] .jy-bars, .jy-root[data-mode="listening"] .jy-bars { display: flex; }
.jy-root[data-mode="listening"] .jy-fab-face { background: var(--danger); box-shadow: 0 0 0 6px rgba(217, 45, 32, .25), 0 10px 28px rgba(217, 45, 32, .45); }
.jy-root[data-mode="listening"] .jy-fab-ring { border-color: rgba(217, 45, 32, .6); animation-duration: 1.2s; }
.jy-root[data-mode="thinking"] .jy-fab-ring { border-style: dashed; animation: jySpin 1.4s linear infinite; }
@keyframes jySpin { to { transform: rotate(360deg); } }
.jy-tip { position: absolute; right: 76px; bottom: 10px; width: max-content; max-width: 220px; background: #000; color: #fff; padding: .65rem .9rem; border: 1px solid rgba(255,255,255,.15); border-radius: 2px; font-size: .85rem; box-shadow: 0 10px 24px rgba(0,0,0,.25); }
.jy-tip[hidden] { display: none; }

/* ---- panel ---- */
.jy-panel { position: absolute; right: 0; bottom: 80px; width: 380px; max-width: calc(100vw - 24px); height: min(560px, calc(100vh - 150px)); background: #fff; border-radius: 4px;
    box-shadow: 0 24px 60px rgba(0,0,0,.3); border: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; animation: jyPop .22s ease-out; 
    transform: scale(1); transform-origin: bottom right; }
.jy-panel[hidden] { display: none; }
@keyframes jyPop { from { opacity: 0; transform: translateY(12px); } }
.jy-head { display: flex; align-items: center; gap: .5rem; padding: .8rem .9rem; background: #000; color: #fff; border-bottom: 2px solid var(--accent); }
.jy-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.2rem; }
.jy-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.jy-title span { font-size: .75rem; opacity: .85; }
.jy-icon { background: rgba(255,255,255,.15); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: .85rem; }
.jy-icon:hover { background: rgba(255,255,255,.3); }
.jy-settings { padding: .8rem 1rem; background: var(--clay-50, #fafaf9); border-bottom: 1px solid var(--clay-200, #e7e5e4); display: flex; flex-direction: column; gap: .65rem; font-size: .82rem; max-height: 55%; overflow: auto; }
.jy-settings[hidden], .jy-reading[hidden] { display: none; }
.jy-settings label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; color: var(--clay-700, #44403c); }
.jy-settings select, .jy-settings input[type=range] { width: 100%; }
.jy-settings select { padding: .4rem; border-radius: .5rem; border: 1px solid var(--clay-300, #d6d3d1); background: #fff; }
.jy-settings .jy-check { flex-direction: row; align-items: center; gap: .5rem; }
.jy-link { align-self: flex-start; background: none; border: 0; color: var(--accent); cursor: pointer; font-size: .82rem; padding: 0; text-decoration: underline; }
.jy-reading { display: flex; align-items: center; gap: .4rem; padding: .5rem .9rem; background: var(--accent-50); border-bottom: 1px solid var(--line); }
.jy-reading-label { flex: 1; font-size: .82rem; font-weight: 600; color: var(--accent-hover); }
.jy-reading button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: #fff; color: var(--accent); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.jy-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: #fff; scroll-behavior: smooth; }
.jy-msg { max-width: 86%; padding: .6rem .85rem; border-radius: 2px; font-size: .92rem; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.jy-msg.bot { align-self: flex-start; background: var(--soft); color: var(--ink); border-bottom-left-radius: 2px; }
.jy-msg.user { align-self: flex-end; background: #000; color: #fff; border-bottom-right-radius: 2px; }
.jy-msg.note { align-self: center; max-width: 94%; background: var(--warning-50); color: var(--warning); font-size: .8rem; text-align: center; border-radius: 2px; }
.jy-msg.typing { display: flex; gap: 4px; padding: .8rem 1rem; }
.jy-msg.typing span { width: 7px; height: 7px; background: var(--clay-400, #a8a29e); border-radius: 50%; animation: jyDot 1.2s infinite; }
.jy-msg.typing span:nth-child(2) { animation-delay: .15s; } .jy-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes jyDot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }
.jy-chips { display: flex; gap: .4rem; padding: .5rem 1rem 0; overflow-x: auto; scrollbar-width: none; background: #fff; }
.jy-chips::-webkit-scrollbar { display: none; }
.jy-chip { flex-shrink: 0; border: 1px solid var(--line-strong); background: var(--accent-50); color: var(--accent-hover); border-radius: 999px; padding: .4rem .8rem; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.jy-chip:hover { background: var(--line); }
.jy-input { display: flex; align-items: center; gap: .5rem; padding: .75rem; background: #fff; }
.jy-input input { flex: 1; min-width: 0; border: 1px solid var(--clay-300, #d6d3d1); border-radius: 999px; padding: .65rem 1rem; font-size: .92rem; font-family: inherit; }
.jy-input input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.jy-mic, .jy-send { flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.jy-mic { background: var(--accent-50); color: var(--accent); }
.jy-mic.on { background: #ef4444; color: #fff; animation: jyBreath 1.1s infinite; }
.jy-mic.jy-nosupport { opacity: .45; }
.jy-send { background: #000; color: #fff; }

/* ---- selection popover ---- */
.jy-selbtn { position: fixed; z-index: 2147482600; display: flex; gap: 2px; background: #000; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: 4px; box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.jy-selbtn[hidden] { display: none; }
.jy-selbtn button { background: none; border: 0; color: #fff; padding: .4rem .75rem; font-size: .8rem; font-weight: 600; cursor: pointer; border-radius: 999px; }
.jy-selbtn button:hover { background: rgba(255,255,255,.18); }

/* ---- read-aloud highlight (works on light and sepia/dark readers) ---- */
.jy-reading-now { background: rgba(0, 139, 116, .18) !important; box-shadow: -8px 0 0 rgba(0, 139, 116, .18), 8px 0 0 rgba(0, 139, 116, .18); border-radius: 4px; transition: background .25s; }

@media (max-width: 560px) {
    .jy-root { --jy-right: 8px; --jy-bottom: 8px; }
    .jy-panel { position: fixed; left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; 
        height: min(78vh, 640px); border-radius: 4px; transform-origin: center bottom; }
    .jy-tip { right: 70px; max-width: 170px; bottom: 8px; }
    .jy-fab { width: 56px; height: 56px; }
    .jy-fab-face b { font-size: 1.5rem; }
    .jy-messages { font-size: 0.9rem; }
    .jy-msg { font-size: 0.88rem; max-width: 90%; }
    .jy-input input { font-size: 0.9rem; padding: 0.6rem 0.85rem; }
}
@media (prefers-reduced-motion: reduce) { .jy-fab-ring, .jy-bars i, .jy-msg.typing span, .jy-panel { animation: none !important; } }
@media print { .jy-root, .vg-mini { display: none !important; } }
