.neo-agent-float {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 28px 14px 28px;
    background: rgba(166, 11, 227, 0.05);
    border: 1.5px solid rgba(166, 11, 227, 0.14);
    border-radius: 60px;
    cursor: pointer;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    box-shadow: 0 4px 20px rgba(166, 11, 227, 0.06), 0 0 0 0 rgba(166, 11, 227, 0);
    transition: box-shadow 0.35s ease, border-color 0.35s ease;
    animation: neoFloatEntry 0.6s ease-out, neoAgentIdle 4s ease-in-out 0.6s infinite, neoAgentGlow 3.5s ease-in-out 0.6s infinite;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.neo-agent-float--hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.9);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.neo-agent-float:hover {
    border-color: rgba(166, 11, 227, 0.38);
    box-shadow: 0 6px 28px rgba(166, 11, 227, 0.10), 0 0 0 3px rgba(166, 11, 227, 0.04);
    animation: none;
    transform: translateY(-3px);
}

.neo-agent-float:focus {
    border-color: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.neo-agent-float:focus:not(:focus-visible) {
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.07);
    border-color: rgba(96, 165, 250, 0.32);
}

.neo-agent-float:active {
    transform: translateY(0);
}

.neo-agent-float__label {
    font-size: 17px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    letter-spacing: -0.2px;
    line-height: 1;
}

.neo-agent-float__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 12%;
    transform: scale(1.25);
    border: 2px solid rgba(166, 11, 227, 0.18);
    box-shadow: 0 0 10px rgba(166, 11, 227, 0.08);
    flex-shrink: 0;
    animation: neoAvatarPulse 3.5s ease-in-out infinite;
}

.neo-agent-float__tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(96, 165, 250, 0.22);
    border-radius: 16px;
    padding: 14px 20px;
    font-size: 13.5px;
    color: #334155;
    line-height: 1.55;
    white-space: pre-line;
    width: 280px;
    max-width: 320px;
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.07);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.neo-agent-float__tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 36px;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.6);
    border-right: 1px solid rgba(96, 165, 250, 0.22);
    border-bottom: 1px solid rgba(96, 165, 250, 0.22);
    transform: rotate(45deg);
}

.neo-agent-float:hover .neo-agent-float__tooltip,
.neo-agent-float:focus .neo-agent-float__tooltip,
.neo-agent-float.neo-agent-float--tooltip-visible .neo-agent-float__tooltip {
    opacity: 1;
    transform: translateY(0);
}

@keyframes neoFloatEntry {
    from { opacity: 0; transform: translateY(24px) scale(0.92); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes neoAgentIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes neoAgentGlow {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(166, 11, 227, 0.06), 0 0 0 0 rgba(166, 11, 227, 0.06);
    }
    50% {
        box-shadow: 0 6px 24px rgba(166, 11, 227, 0.10), 0 0 0 5px rgba(166, 11, 227, 0);
    }
}

@keyframes neoAvatarPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(166, 11, 227, 0.08);
    }
    50% {
        box-shadow: 0 0 16px rgba(166, 11, 227, 0.14);
    }
}

@media (max-width: 768px) {
    .neo-agent-float {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        padding: 8px 14px;
        gap: 10px;
        animation: neoFloatEntry 0.6s ease-out;
    }
    .neo-agent-float__avatar {
        width: 36px;
        height: 36px;
        transform: scale(1);
        animation: none;
    }
    .neo-agent-float__label {
        font-size: 13px;
    }
    .neo-agent-float__tooltip {
        right: -8px;
        width: 250px;
        max-width: 280px;
    }
    .neo-agent-float__tooltip::after {
        right: 44px;
    }
}

@media (max-width: 480px) {
    .neo-agent-float {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        right: 12px;
        padding: 6px 12px;
        gap: 8px;
    }
    .neo-agent-float__avatar {
        width: 32px;
        height: 32px;
    }
    .neo-agent-float__label {
        display: none;
    }
    .neo-agent-float__tooltip {
        width: 230px;
    }
}

[data-theme="dark"] .neo-agent-float {
    background: rgba(166, 11, 227, 0.06);
    border-color: rgba(166, 11, 227, 0.16);
    box-shadow: 0 4px 20px rgba(166, 11, 227, 0.05), 0 0 12px rgba(166, 11, 227, 0.03);
}

[data-theme="dark"] .neo-agent-float:hover {
    border-color: rgba(166, 11, 227, 0.40);
    box-shadow: 0 6px 28px rgba(166, 11, 227, 0.12), 0 0 16px rgba(166, 11, 227, 0.06);
}

[data-theme="dark"] .neo-agent-float__label {
    color: #e2e8f0;
}

[data-theme="dark"] .neo-agent-float__avatar {
    border-color: rgba(166, 11, 227, 0.25);
    box-shadow: 0 0 12px rgba(166, 11, 227, 0.10);
}

[data-theme="dark"] .neo-agent-float__tooltip {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(96, 165, 250, 0.25);
    color: #cbd5e1;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), 0 0 16px rgba(96, 165, 250, 0.06);
}

[data-theme="dark"] .neo-agent-float__tooltip::after {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(96, 165, 250, 0.25);
}

@keyframes neoAgentGlowDark {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(166, 11, 227, 0.08), 0 0 12px rgba(166, 11, 227, 0.04), 0 0 0 0 rgba(166, 11, 227, 0.06);
    }
    50% {
        box-shadow: 0 6px 24px rgba(166, 11, 227, 0.12), 0 0 16px rgba(166, 11, 227, 0.06), 0 0 0 4px rgba(166, 11, 227, 0);
    }
}

[data-theme="dark"] .neo-agent-float {
    animation: neoFloatEntry 0.6s ease-out, neoAgentIdle 4s ease-in-out 0.6s infinite, neoAgentGlowDark 3.5s ease-in-out 0.6s infinite;
}

[data-theme="dark"] .neo-agent-float:hover {
    animation: none;
}

@keyframes neoAvatarPulseDark {
    0%, 100% {
        box-shadow: 0 0 12px rgba(166, 11, 227, 0.10);
    }
    50% {
        box-shadow: 0 0 18px rgba(166, 11, 227, 0.16);
    }
}

[data-theme="dark"] .neo-agent-float__avatar {
    animation: neoAvatarPulseDark 3.5s ease-in-out infinite;
}

[dir="rtl"] .neo-agent-float {
    right: auto;
    left: 28px;
    flex-direction: row-reverse;
}

[dir="rtl"] .neo-agent-float__tooltip {
    right: auto;
    left: 0;
}

[dir="rtl"] .neo-agent-float__tooltip::after {
    right: auto;
    left: 36px;
}

@media (max-width: 768px) {
    [dir="rtl"] .neo-agent-float {
        left: 16px;
        right: auto;
    }
}

@media (max-width: 480px) {
    [dir="rtl"] .neo-agent-float {
        left: 12px;
        right: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .neo-agent-float {
        animation: none !important;
    }
    .neo-agent-float__avatar {
        animation: none !important;
    }
    .neo-agent-float__tooltip {
        transition: none;
    }
}

.neo-agent-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.82);
    border-left: 1.5px solid rgba(166, 11, 227, 0.12);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    box-shadow: -8px 0 40px rgba(166, 11, 227, 0.06), -2px 0 12px rgba(0,0,0,0.04);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.neo-agent-panel--open {
    transform: translateX(0);
}

.neo-agent-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(166, 11, 227, 0.10);
    flex-shrink: 0;
}

.neo-agent-panel__header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.neo-agent-panel__header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 12%;
    border: 1.5px solid rgba(166, 11, 227, 0.18);
}

.neo-agent-panel__header-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.3px;
}

.neo-agent-panel__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    color: #64748b;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
}

.neo-agent-panel__close:hover {
    background: rgba(166, 11, 227, 0.08);
    color: #a60be3;
}

.neo-agent-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.neo-agent-panel__welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    gap: 12px;
    flex: 1;
}

.neo-agent-panel__welcome-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 12%;
    border: 2px solid rgba(166, 11, 227, 0.16);
    box-shadow: 0 0 20px rgba(166, 11, 227, 0.08);
}

.neo-agent-panel__welcome-title {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.neo-agent-panel__welcome-desc {
    font-size: 13.5px;
    color: #64748b;
    line-height: 1.5;
    max-width: 300px;
}

.neo-agent-panel__msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.neo-agent-panel__msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(166, 11, 227, 0.12), rgba(96, 165, 250, 0.10));
    color: #1e293b;
    border-bottom-right-radius: 4px;
}

.neo-agent-panel__msg--assistant {
    align-self: flex-start;
    background: rgba(241, 245, 249, 0.8);
    color: #334155;
    border-bottom-left-radius: 4px;
}

.neo-agent-panel__msg--assistant h3,
.neo-agent-panel__msg--assistant h4 {
    font-size: 14px;
    font-weight: 700;
    margin: 8px 0 4px 0;
    color: #1e293b;
}

.neo-agent-panel__msg--assistant ul {
    margin: 4px 0;
    padding-left: 18px;
}

.neo-agent-panel__msg--assistant li {
    margin: 2px 0;
}

.neo-agent-panel__msg--assistant code {
    background: rgba(166, 11, 227, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12.5px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.neo-agent-panel__msg--assistant pre {
    background: rgba(15, 23, 42, 0.06);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 6px 0;
}

.neo-agent-panel__msg--assistant pre code {
    background: none;
    padding: 0;
}

.neo-agent-panel__msg--assistant strong {
    font-weight: 650;
    color: #1e293b;
}

.neo-agent-panel__screenshot-bar {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(166, 11, 227, 0.06);
    border-top: 1px solid rgba(166, 11, 227, 0.08);
    flex-shrink: 0;
}

.neo-agent-panel__screenshot-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: #7c3aed;
    font-weight: 500;
}

.neo-agent-panel__screenshot-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #94a3b8;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}

.neo-agent-panel__screenshot-remove:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.neo-agent-panel__input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(166, 11, 227, 0.10);
    flex-shrink: 0;
}

.neo-agent-panel__btn-screenshot {
    background: none;
    border: 1.5px solid rgba(166, 11, 227, 0.18);
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    color: #7c3aed;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.neo-agent-panel__btn-screenshot:hover {
    background: rgba(166, 11, 227, 0.08);
    border-color: rgba(166, 11, 227, 0.30);
}

.neo-agent-panel__btn-screenshot:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.neo-agent-panel__btn-screenshot--loading {
    animation: neoAgentSpin 1s linear infinite;
}

@keyframes neoAgentSpin {
    to { transform: rotate(360deg); }
}

.neo-agent-panel__input {
    flex: 1;
    border: 1.5px solid rgba(166, 11, 227, 0.14);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.6);
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.neo-agent-panel__input::placeholder {
    color: #94a3b8;
}

.neo-agent-panel__input:focus {
    border-color: rgba(166, 11, 227, 0.35);
}

.neo-agent-panel__input:disabled {
    opacity: 0.5;
}

.neo-agent-panel__btn-send {
    background: linear-gradient(135deg, #a60be3, #7c3aed);
    border: none;
    cursor: pointer;
    padding: 9px;
    border-radius: 10px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.neo-agent-panel__btn-send:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

.neo-agent-panel__btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.neo-agent-thinking {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #7c3aed;
    font-style: italic;
    font-size: 13.5px;
}

.neo-agent-thinking::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(166, 11, 227, 0.2);
    border-top-color: #a60be3;
    border-radius: 50%;
    animation: neoAgentSpin 0.8s linear infinite;
    flex-shrink: 0;
}

[data-theme="dark"] .neo-agent-panel {
    background: rgba(15, 23, 42, 0.88);
    border-left-color: rgba(166, 11, 227, 0.16);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.25), -2px 0 12px rgba(0,0,0,0.15);
}

[data-theme="dark"] .neo-agent-panel__header {
    border-bottom-color: rgba(166, 11, 227, 0.12);
}

[data-theme="dark"] .neo-agent-panel__header-title {
    color: #e2e8f0;
}

[data-theme="dark"] .neo-agent-panel__close {
    color: #94a3b8;
}

[data-theme="dark"] .neo-agent-panel__close:hover {
    background: rgba(166, 11, 227, 0.12);
    color: #c084fc;
}

[data-theme="dark"] .neo-agent-panel__welcome-title {
    color: #e2e8f0;
}

[data-theme="dark"] .neo-agent-panel__welcome-desc {
    color: #94a3b8;
}

[data-theme="dark"] .neo-agent-panel__msg--user {
    background: linear-gradient(135deg, rgba(166, 11, 227, 0.18), rgba(96, 165, 250, 0.12));
    color: #e2e8f0;
}

[data-theme="dark"] .neo-agent-panel__msg--assistant {
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
}

[data-theme="dark"] .neo-agent-panel__msg--assistant h3,
[data-theme="dark"] .neo-agent-panel__msg--assistant h4 {
    color: #e2e8f0;
}

[data-theme="dark"] .neo-agent-panel__msg--assistant strong {
    color: #e2e8f0;
}

[data-theme="dark"] .neo-agent-panel__msg--assistant code {
    background: rgba(166, 11, 227, 0.14);
}

[data-theme="dark"] .neo-agent-panel__msg--assistant pre {
    background: rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .neo-agent-panel__input-area {
    border-top-color: rgba(166, 11, 227, 0.12);
}

[data-theme="dark"] .neo-agent-panel__input {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(166, 11, 227, 0.18);
    color: #e2e8f0;
}

[data-theme="dark"] .neo-agent-panel__input::placeholder {
    color: #64748b;
}

[data-theme="dark"] .neo-agent-panel__input:focus {
    border-color: rgba(166, 11, 227, 0.40);
}

[data-theme="dark"] .neo-agent-panel__btn-screenshot {
    border-color: rgba(166, 11, 227, 0.22);
    color: #c084fc;
}

[data-theme="dark"] .neo-agent-panel__btn-screenshot:hover {
    background: rgba(166, 11, 227, 0.12);
}

[data-theme="dark"] .neo-agent-panel__screenshot-bar {
    background: rgba(166, 11, 227, 0.08);
    border-top-color: rgba(166, 11, 227, 0.10);
}

[data-theme="dark"] .neo-agent-panel__screenshot-badge {
    color: #c084fc;
}

[data-theme="dark"] .neo-agent-thinking {
    color: #c084fc;
}

[dir="rtl"] .neo-agent-panel {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1.5px solid rgba(166, 11, 227, 0.12);
    transform: translateX(-100%);
    box-shadow: 8px 0 40px rgba(166, 11, 227, 0.06), 2px 0 12px rgba(0,0,0,0.04);
}

[dir="rtl"] .neo-agent-panel--open {
    transform: translateX(0);
}

[dir="rtl"] .neo-agent-panel__msg--user {
    align-self: flex-start;
    border-bottom-right-radius: 14px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .neo-agent-panel__msg--assistant {
    align-self: flex-end;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

@media (max-width: 480px) {
    .neo-agent-panel {
        width: 100vw;
        top: auto;
        right: 0;
        bottom: 0;
        height: 65svh;
        height: 65dvh;
        max-height: 65dvh;
        min-height: 320px;
        border-radius: 18px 18px 0 0;
        overflow: hidden;
        padding-top: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }
    .neo-agent-panel__header {
        position: sticky;
        top: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        z-index: 2;
        flex-shrink: 0;
    }
    .neo-agent-panel__messages {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .neo-agent-panel__input-area {
        flex-shrink: 0;
    }
    .neo-agent-panel__close {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }
    .neo-agent-panel__close svg { width: 22px; height: 22px; }
    /* iOS Safari zooms in on focus when input font-size < 16px.
       Force 16px on the composer to prevent that zoom. */
    .neo-agent-panel__input,
    .neo-agent-panel__input-area textarea,
    .neo-agent-panel__input-area input {
        font-size: 16px !important;
    }
}
