.ytp-ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ytp-ai-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #5258e4;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(82, 88, 228, .45);
    transition: transform .15s ease, box-shadow .15s ease;
}
.ytp-ai-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(82, 88, 228, .55);
}

.ytp-ai-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(30, 20, 90, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(.98);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.ytp-ai-panel.ytp-ai-panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ytp-ai-header {
    padding: 16px 18px;
    background: linear-gradient(135deg, #5258e4 0%, #6a63ff 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
}
.ytp-ai-header button {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    opacity: .85;
}
.ytp-ai-header button:hover {
    opacity: 1;
}

.ytp-ai-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ytp-ai-msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.ytp-ai-msg-user {
    align-self: flex-end;
    background: #5258e4;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ytp-ai-msg-assistant {
    align-self: flex-start;
    background: linear-gradient(0deg, rgba(255, 255, 255, 0) 0%, rgba(82, 88, 228, .12) 100%), rgba(82, 88, 228, .06);
    color: #29254d;
    border: 1px solid rgba(82, 88, 228, .15);
    border-bottom-left-radius: 4px;
}
.ytp-ai-msg a {
    color: #5258e4;
    font-weight: 600;
    text-decoration: underline;
    overflow-wrap: anywhere;
}

.ytp-ai-sources {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    padding-left: 6px;
}
.ytp-ai-sources a {
    color: #5258e4;
    overflow-wrap: anywhere;
}

.ytp-ai-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 10px;
}
.ytp-ai-chip {
    border: 1px solid rgba(82, 88, 228, .3);
    background: rgba(82, 88, 228, .06);
    color: #5258e4;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease;
}
.ytp-ai-chip:hover {
    background: rgba(82, 88, 228, .16);
}

.ytp-ai-form {
    display: flex;
    border-top: 1px solid rgba(82, 88, 228, .12);
    padding: 10px;
    gap: 8px;
}
.ytp-ai-form input {
    flex: 1;
    border: 1px solid rgba(82, 88, 228, .25);
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 14px;
}
.ytp-ai-form input:focus {
    outline: none;
    border-color: #5258e4;
    box-shadow: 0 0 0 3px rgba(82, 88, 228, .15);
}
.ytp-ai-form button {
    background: #5258e4;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}
.ytp-ai-form button:hover {
    background: #4247c4;
}

@media (prefers-color-scheme: dark) {
    .ytp-ai-panel { background: #1e1e26; }
    .ytp-ai-header { background: linear-gradient(135deg, #4247c4 0%, #5a54d6 100%); }
    .ytp-ai-msg-assistant { background: rgba(130, 135, 245, .12); color: #e8e7ff; border-color: rgba(130, 135, 245, .25); }
    .ytp-ai-sources a, .ytp-ai-msg a { color: #a5a9ff; }
    .ytp-ai-chip { color: #a5a9ff; background: rgba(130, 135, 245, .12); border-color: rgba(130, 135, 245, .3); }
    .ytp-ai-form { border-top-color: rgba(130, 135, 245, .2); }
    .ytp-ai-form input { background: #2a2a35; color: #eee; border-color: rgba(130, 135, 245, .3); }
}
