:root {
    --aidc-accent: #4f46e5;
    --aidc-accent-hover: #4338ca;
    --aidc-bg: #ffffff;
    --aidc-bg-alt: #f8f8fb;
    --aidc-text: #18181b;
    --aidc-text-muted: #6b7280;
    --aidc-border: #e5e7eb;
    --aidc-shadow: 0 10px 40px rgba(0,0,0,0.15);
    --aidc-radius: 14px;
}

#aidc-widget-root {
    position: fixed;
    z-index: 999999;
    bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#aidc-widget-root.aidc-position-bottom-right { right: 20px; }
#aidc-widget-root.aidc-position-bottom-left  { left: 20px; }

.aidc-launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--aidc-accent);
    color: #fff;
    box-shadow: var(--aidc-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.15s;
}
.aidc-launcher:hover {
    background: var(--aidc-accent-hover);
    transform: scale(1.05);
}

.aidc-panel {
    position: absolute;
    bottom: 70px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 100px);
    background: var(--aidc-bg);
    border-radius: var(--aidc-radius);
    box-shadow: var(--aidc-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--aidc-border);
}
#aidc-widget-root.aidc-position-bottom-right .aidc-panel { right: 0; }
#aidc-widget-root.aidc-position-bottom-left  .aidc-panel { left: 0; }
.aidc-panel.aidc-open { display: flex; }

.aidc-header {
    background: var(--aidc-accent);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.aidc-title { font-weight: 600; font-size: 15px; }
.aidc-close {
    background: transparent;
    color: #fff;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.aidc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--aidc-bg-alt);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aidc-msg {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}
.aidc-msg-user {
    align-self: flex-end;
    background: var(--aidc-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.aidc-msg-assistant {
    align-self: flex-start;
    background: #fff;
    color: var(--aidc-text);
    border: 1px solid var(--aidc-border);
    border-bottom-left-radius: 4px;
}
.aidc-msg-content a { color: inherit; text-decoration: underline; }

.aidc-sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--aidc-border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.aidc-sources-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--aidc-text-muted);
    width: 100%;
    margin-bottom: 2px;
    letter-spacing: 0.04em;
}
.aidc-source {
    background: var(--aidc-bg-alt);
    border: 1px solid var(--aidc-border);
    color: var(--aidc-text);
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    text-decoration: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
a.aidc-source:hover { border-color: var(--aidc-accent); color: var(--aidc-accent); }

.aidc-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 16px;
}
.aidc-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--aidc-text-muted);
    animation: aidc-bounce 1.2s infinite ease-in-out;
}
.aidc-typing span:nth-child(2) { animation-delay: 0.15s; }
.aidc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aidc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.aidc-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--aidc-border);
    background: var(--aidc-bg);
}
.aidc-input textarea {
    flex: 1;
    border: 1px solid var(--aidc-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    outline: none;
    color: var(--aidc-text);
    background: var(--aidc-bg);
    min-height: 40px;
    max-height: 120px;
}
.aidc-input textarea:focus { border-color: var(--aidc-accent); }
.aidc-input button {
    background: var(--aidc-accent);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.aidc-input button:hover { background: var(--aidc-accent-hover); }
.aidc-input button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
    .aidc-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 90px);
        bottom: 70px;
    }
}
