.jb-ai-launcher {
    position: fixed;
    bottom: calc(max(1.5rem, env(safe-area-inset-bottom)) + 4.5rem);
    right: 1.5rem;
    z-index: var(--jb-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1rem;
    border-radius: var(--jb-radius-pill);
    background: var(--jb-surface-raised);
    border: 1px solid var(--jb-border);
    color: var(--jb-white);
    font-family: var(--jb-font-mono);
    font-size: var(--jb-text-sm);
    font-weight: var(--jb-font-medium);
    cursor: pointer;
    box-shadow: var(--jb-shadow-md);
    transition: transform var(--jb-duration-fast) var(--jb-ease), background-color var(--jb-duration-fast) var(--jb-ease), border-color var(--jb-duration-fast) var(--jb-ease);
}
.jb-ai-launcher:hover, .jb-ai-launcher:focus-visible {
    transform: translateY(-2px);
    background: var(--jb-surface-hover);
    border-color: var(--jb-green);
    color: var(--jb-green);
    outline: none;
}
.jb-ai-launcher:focus-visible {
    box-shadow: 0 0 0 2px var(--jb-black), 0 0 0 4px var(--jb-green);
}
@media (min-width: 768px) {
    .jb-ai-launcher {
        bottom: 5.5rem;
        right: 2rem;
    }
}

.jb-ai-window {
    position: fixed;
    z-index: calc(var(--jb-z-modal) + 1);
    background: var(--jb-surface-raised);
    border: 1px solid var(--jb-border);
    border-radius: var(--jb-radius-md);
    box-shadow: var(--jb-shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
    transition: opacity var(--jb-duration-fast) var(--jb-ease), transform var(--jb-duration-fast) var(--jb-ease);
}
.jb-ai-window[hidden] {
    display: none;
    opacity: 0;
    transform: translateY(10px);
}

@media (min-width: 768px) {
    .jb-ai-window {
        bottom: calc(5.5rem + 50px);
        right: 2rem;
        width: 360px;
        height: 500px;
        max-height: calc(100vh - 4rem - 120px);
    }
}
@media (max-width: 767px) {
    .jb-ai-window {
        bottom: max(1rem, env(safe-area-inset-bottom));
        left: 1rem;
        right: 1rem;
        width: auto;
        height: calc(100dvh - max(2rem, env(safe-area-inset-bottom) * 2));
        max-height: 550px;
        box-sizing: border-box;
    }
}

.jb-ai-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.2rem;
    border-bottom: 1px solid var(--jb-border);
    background: var(--jb-surface);
}
.jb-ai-title {
    margin: 0 0 0.2rem 0;
    font-family: var(--jb-font-display);
    font-size: var(--jb-text-base);
    color: var(--jb-white);
    letter-spacing: 0.05em;
}
.jb-ai-subtitle {
    margin: 0;
    font-family: var(--jb-font-body);
    font-size: var(--jb-text-xs);
    color: var(--jb-text-muted);
    line-height: var(--jb-leading-snug);
}
.jb-ai-close {
    background: transparent;
    border: none;
    color: var(--jb-text-muted);
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--jb-radius-sm);
    transition: color var(--jb-duration-fast) var(--jb-ease), background-color var(--jb-duration-fast) var(--jb-ease);
}
.jb-ai-close:hover, .jb-ai-close:focus-visible {
    color: var(--jb-white);
    background: var(--jb-surface-hover);
    outline: none;
}
.jb-ai-close:focus-visible {
    box-shadow: 0 0 0 2px var(--jb-green);
}

.jb-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-family: var(--jb-font-body);
    font-size: var(--jb-text-sm);
    color: var(--jb-text);
}
.jb-ai-messages::-webkit-scrollbar {
    width: 6px;
}
.jb-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}
.jb-ai-messages::-webkit-scrollbar-thumb {
    background: var(--jb-border);
    border-radius: var(--jb-radius-pill);
}

.jb-ai-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}
.jb-ai-msg--user {
    align-self: flex-end;
}
.jb-ai-msg--assistant {
    align-self: flex-start;
}
.jb-ai-msg-content {
    padding: 0.8rem 1rem;
    border-radius: var(--jb-radius-md);
    line-height: var(--jb-leading-normal);
    overflow-wrap: anywhere;
    word-break: break-word;
}
.jb-ai-msg--user .jb-ai-msg-content {
    background: var(--jb-surface-hover);
    border: 1px solid var(--jb-border-light);
    color: var(--jb-white);
    border-bottom-right-radius: 2px;
}
.jb-ai-msg--assistant .jb-ai-msg-content {
    background: var(--jb-surface);
    border: 1px solid var(--jb-border-green);
    color: var(--jb-white);
    border-bottom-left-radius: 2px;
}

.jb-ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.jb-ai-suggest-btn {
    background: transparent;
    border: 1px solid var(--jb-border);
    border-radius: var(--jb-radius-pill);
    color: var(--jb-green);
    font-family: var(--jb-font-mono);
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    transition: all var(--jb-duration-fast) var(--jb-ease);
}
.jb-ai-suggest-btn:hover, .jb-ai-suggest-btn:focus-visible {
    background: var(--jb-green);
    color: var(--jb-black);
    border-color: var(--jb-green);
    outline: none;
}
.jb-ai-suggest-btn:focus-visible {
    box-shadow: 0 0 0 2px var(--jb-black), 0 0 0 4px var(--jb-green);
}

.jb-ai-form {
    display: flex;
    padding: 0.8rem;
    border-top: 1px solid var(--jb-border);
    background: var(--jb-surface);
    gap: 0.5rem;
}
.jb-ai-input {
    flex: 1;
    background: var(--jb-bg);
    border: 1px solid var(--jb-border);
    border-radius: var(--jb-radius-sm);
    color: var(--jb-white);
    font-family: var(--jb-font-body);
    font-size: var(--jb-text-sm);
    padding: 0.6rem 0.8rem;
    transition: border-color var(--jb-duration-fast) var(--jb-ease);
}
.jb-ai-input:focus {
    outline: none;
    border-color: var(--jb-green);
}
.jb-ai-submit {
    background: var(--jb-green);
    color: var(--jb-black);
    border: none;
    border-radius: var(--jb-radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--jb-duration-fast) var(--jb-ease);
}
.jb-ai-submit:hover, .jb-ai-submit:focus-visible {
    background: var(--jb-primary-hover);
    outline: none;
}
.jb-ai-submit:focus-visible {
    box-shadow: 0 0 0 2px var(--jb-black), 0 0 0 4px var(--jb-green);
}
.jb-ai-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}
/* Markdown Styles */
.jb-ai-msg-content p { margin: 0 0 0.8rem 0; }
.jb-ai-msg-content p:last-child { margin-bottom: 0; }
.jb-ai-msg-content a {
    color: var(--jb-green);
    text-decoration: none;
    font-weight: var(--jb-font-medium);
    border-bottom: 1px solid transparent;
    transition: border-color var(--jb-duration-fast) var(--jb-ease);
}
.jb-ai-msg-content a:hover,
.jb-ai-msg-content a:focus-visible {
    border-bottom-color: var(--jb-green);
    outline: none;
}
.jb-ai-msg-content a:focus-visible {
    border-radius: 2px;
    box-shadow: 0 0 0 2px var(--jb-black), 0 0 0 4px var(--jb-green);
}
.jb-ai-msg-content strong { font-weight: 700; }
.jb-ai-msg-content em { font-style: italic; }
.jb-ai-msg-content ul,
.jb-ai-msg-content ol { margin: 0 0 0.8rem 0; padding-left: 1.2rem; }
.jb-ai-msg-content ul:last-child,
.jb-ai-msg-content ol:last-child { margin-bottom: 0; }
.jb-ai-msg-content li { margin-bottom: 0.2rem; }
.jb-ai-msg-content li:last-child { margin-bottom: 0; }
/* Mobile specific overrides */
@media (max-width: 767px) {
    .jb-ai-input {
        font-size: 16px; /* Prevent iOS Safari auto-zoom */
    }
    .jb-ai-msg {
        max-width: 90%;
    }
}
