#phoenix-wa-widget {
    --phoenix-wa-anchor-top: 88px;
    position: fixed;
    top: var(--phoenix-wa-anchor-top);
    right: 16px;
    z-index: 9999;
    font-family: "Segoe UI", Tahoma, sans-serif;
}

#phoenix-wa-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    background: linear-gradient(135deg, #0f264f 0%, #184d8f 58%, #2575d1 100%);
    color: #ffffff;
    cursor: grab;
    box-shadow: 0 16px 34px rgba(19, 72, 136, 0.42), 0 0 0 1px rgba(40, 152, 255, 0.24);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    animation: phoenix-wa-button-pulse 2.4s ease-in-out infinite;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    /* Promote only the animated button to its own GPU compositor layer.
       Putting will-change on the widget CONTAINER would break position:fixed
       on the panel (any transform/will-change on an ancestor makes it the
       new containing block for fixed descendants). The toggle button is the
       only element that actually animates, so isolate it here instead. */
    will-change: transform;
}

#phoenix-wa-toggle:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 20px 40px rgba(19, 72, 136, 0.52), 0 0 0 1px rgba(89, 190, 255, 0.34);
    filter: saturate(1.1);
}

#phoenix-wa-toggle.is-dragging {
    cursor: grabbing;
    animation: none;
    transform: scale(1.04);
}

.phoenix-wa-icon {
    font-size: 42px;
    line-height: 1;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.phoenix-wa-icon-label {
    display: none;
}

#phoenix-wa-passive-hint {
    position: absolute;
    top: 72px;
    right: 0;
    background: #f4f9ff;
    border: 1px solid #b6d5f8;
    border-radius: 12px;
    padding: 9px 12px;
    color: #16345e;
    white-space: nowrap;
    box-shadow: 0 10px 26px rgba(14, 60, 112, 0.2);
    font-size: 13px;
    font-weight: 700;
}

#phoenix-wa-panel {
    position: fixed;
    top: var(--phoenix-wa-anchor-top);
    right: 0;
    width: 30vw;
    min-width: 320px;
    max-width: 560px;
    height: calc(100vh - var(--phoenix-wa-anchor-top) - 10px);
    min-height: 300px;
    background: #ffffff;
    border-left: 1px solid #dfe6ee;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    box-shadow: -14px 0 34px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Resize grip — bottom-LEFT corner (panel is right-anchored;
   drag left = wider, drag right = narrower) */
#phoenix-wa-resize {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 22px;
    height: 22px;
    cursor: sw-resize;
    z-index: 10;
    touch-action: none;
}

#phoenix-wa-resize::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 12px;
    height: 12px;
    border-left: 2px solid rgba(100, 130, 160, 0.55);
    border-bottom: 2px solid rgba(100, 130, 160, 0.55);
}

#phoenix-wa-panel[hidden] {
    display: none;
}

#phoenix-wa-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    background: #152238;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#phoenix-wa-header.is-dragging {
    cursor: grabbing;
}

#phoenix-wa-header span {
    flex: 1;
}

#phoenix-wa-new,
#phoenix-wa-close {
    border: none;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    opacity: 0.85;
    padding: 3px 5px;
    border-radius: 6px;
}

#phoenix-wa-new:hover,
#phoenix-wa-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.14);
}

/* ── Synthesis mode toggle (Fast / Deep pill) ── */
#phoenix-wa-mode-toggle {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 20px;
    padding: 2px;
    gap: 0;
}

.phoenix-wa-mode-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 9px;
    border-radius: 16px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: background 0.18s, color 0.18s;
}

.phoenix-wa-mode-btn.is-active {
    background: #ffffff;
    color: #152238;
}

.phoenix-wa-mode-btn:hover:not(.is-active) {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.12);
}

/* Indicator in composer area when deep mode is active */
#phoenix-wa-composer.deep-mode::before {
    content: '⚡ Deep Analysis';
    display: block;
    font-size: 10px;
    color: #2563eb;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 4px 12px 0;
    opacity: 0.8;
}

#phoenix-wa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7fafc;
}

.phoenix-wa-msg {
    max-width: 94%;
    border-radius: 10px;
    padding: 9px 11px;
    line-height: 1.45;
    font-size: 13px;
    word-break: break-word;
}

.phoenix-wa-msg--user {
    align-self: flex-end;
    background: #152238;
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.phoenix-wa-msg--agent {
    align-self: flex-start;
    background: #ffffff;
    color: #203047;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 2px;
}

.phoenix-wa-msg--error {
    align-self: stretch;
    background: #fff4f4;
    color: #ab1f2a;
    border: 1px solid #fecaca;
    text-align: center;
}

.phoenix-wa-msg--thinking {
    border-style: dashed;
}

.phoenix-wa-thinking {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1d3557;
}

.phoenix-wa-thinking-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1f6fbb;
    box-shadow: 0 0 0 0 rgba(31, 111, 187, 0.45);
    animation: phoenix-wa-dot-pulse 1.1s ease-in-out infinite;
}

.phoenix-wa-answer {
    margin: 0;
}

.phoenix-wa-answer h2 {
    margin: 6px 0 4px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: #0f172a;
}

.phoenix-wa-answer h3 {
    margin: 5px 0 3px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    color: #1e293b;
}

.phoenix-wa-answer p {
    margin: 4px 0;
    line-height: 1.45;
}

.phoenix-wa-answer ul,
.phoenix-wa-answer ol {
    margin: 4px 0 4px 18px;
    padding: 0;
}

.phoenix-wa-answer li {
    margin: 1px 0;
    line-height: 1.4;
}

.phoenix-wa-answer code {
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
}

.phoenix-wa-answer strong {
    font-weight: 600;
}

.phoenix-wa-answer > *:first-child {
    margin-top: 0;
}

.phoenix-wa-answer > *:last-child {
    margin-bottom: 0;
}

.phoenix-wa-related-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}

.phoenix-wa-related-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid #b6cfe8;
    border-radius: 14px;
    background: #f0f6ff;
    color: #1a3a6b;
    font-size: 11.5px;
    font-family: inherit;
    line-height: 1.35;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.phoenix-wa-related-btn:hover {
    background: #152238;
    border-color: #152238;
    color: #ffffff;
}

.phoenix-wa-hint {
    margin: 6px 0 0;
    color: #005fb8;
    font-size: 12px;
    font-weight: 700;
}

#phoenix-wa-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

#phoenix-wa-input {
    flex: 1;
    resize: none;
    min-height: 36px;
    max-height: 120px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    padding: 8px 10px;
    outline: none;
    font-size: 13px;
    line-height: 1.4;
    font-family: inherit;
}

#phoenix-wa-input:focus {
    border-color: #152238;
}

#phoenix-wa-send {
    border: none;
    border-radius: 8px;
    background: #152238;
    color: #ffffff;
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

#phoenix-wa-send:hover {
    background: #0f1a2c;
}

#phoenix-wa-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.phoenix-wa-msg--streaming {
    border-style: dashed;
}

.phoenix-wa-streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background: #1f6fbb;
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: phoenix-wa-cursor-blink 0.75s ease-in-out infinite;
}

@keyframes phoenix-wa-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes phoenix-wa-button-pulse {
    0%   { transform: scale(1.00); opacity: 1; }
    55%  { transform: scale(1.04); opacity: 0.90; }
    100% { transform: scale(1.00); opacity: 1; }
}

@keyframes phoenix-wa-dot-pulse {
    0% {
        transform: scale(0.92);
        box-shadow: 0 0 0 0 rgba(31, 111, 187, 0.45);
    }
    60% {
        transform: scale(1.12);
        box-shadow: 0 0 0 8px rgba(31, 111, 187, 0);
    }
    100% {
        transform: scale(0.92);
        box-shadow: 0 0 0 0 rgba(31, 111, 187, 0);
    }
}

@media (max-width: 991px) {
    #phoenix-wa-panel {
        width: min(92vw, 460px);
        min-width: 0;
    }
}

@media (max-width: 640px) {
    #phoenix-wa-widget {
        top: auto;
        bottom: 14px;
        right: 10px;
    }

    #phoenix-wa-toggle {
        width: 62px;
        height: 62px;
    }

    .phoenix-wa-icon {
        font-size: 34px;
    }

    #phoenix-wa-panel {
        top: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        max-width: none;
    }
}
