#cwp-widget-root,
#cwp-widget-root *,
#cwp-widget-root *::before,
#cwp-widget-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    vertical-align: baseline;
    line-height: normal;
    -webkit-text-size-adjust: 100%;
}

#cwp-widget-root {
    touch-action: manipulation;
    font-family: var(--cwp-font);
    font-size: 14px;
    color: var(--cwp-msg-bot-text);
}

#cwp-widget-root .cwp-launcher {
    position: fixed;
    z-index: 999990;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    padding: 0;
    outline: none;
    transition: transform 0.2s ease;
}
#cwp-widget-root .cwp-launcher:hover {
    transform: scale(1.08);
}
#cwp-widget-root .cwp-launcher-icon {
    width: var(--cwp-launcher-size);
    height: var(--cwp-launcher-size);
    border-radius: 50%;
    background: var(--cwp-primary);
    color: var(--cwp-text);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.2s ease;
}
#cwp-widget-root .cwp-launcher:hover .cwp-launcher-icon {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
#cwp-widget-root .cwp-launcher-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}
#cwp-widget-root .cwp-launcher-text {
    font-family: var(--cwp-font);
    font-size: 11px;
    font-weight: 600;
    color: var(--cwp-primary);
}
#cwp-widget-root .cwp-launcher.cwp-mode-icon .cwp-launcher-text { display: none; }
#cwp-widget-root .cwp-launcher.cwp-mode-text .cwp-launcher-icon { display: none; }
#cwp-widget-root .cwp-launcher.cwp-mode-text {
    background: var(--cwp-primary);
    color: var(--cwp-text);
    padding: 12px 20px;
    border-radius: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
#cwp-widget-root .cwp-launcher.cwp-mode-text .cwp-launcher-text {
    color: var(--cwp-text);
    font-size: 14px;
}

#cwp-widget-root .cwp-window {
    position: fixed;
    z-index: 999991;
    width: var(--cwp-window-width);
    height: var(--cwp-window-height);
    max-height: calc(100vh - 100px);
    background: var(--cwp-bg);
    border-radius: var(--cwp-radius);
    box-shadow: var(--cwp-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
#cwp-widget-root .cwp-window.cwp-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#cwp-widget-root .cwp-header {
    background: var(--cwp-header-bg);
    color: var(--cwp-text);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#cwp-widget-root .cwp-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#cwp-widget-root .cwp-header-avatar svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}
#cwp-widget-root .cwp-header-info {
    flex: 1;
    min-width: 0;
}
#cwp-widget-root .cwp-header-name {
    font-family: var(--cwp-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}
#cwp-widget-root .cwp-header-status {
    font-family: var(--cwp-font);
    font-size: 11px;
    opacity: 0.8;
    line-height: 1.3;
}
#cwp-widget-root .cwp-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
#cwp-widget-root .cwp-header-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#cwp-widget-root .cwp-header-btn:hover {
    opacity: 1;
}
#cwp-widget-root .cwp-header-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

#cwp-widget-root .cwp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}

#cwp-widget-root .cwp-welcome {
    text-align: center;
    padding: 20px 12px;
}
#cwp-widget-root .cwp-welcome-title {
    font-family: var(--cwp-font);
    font-size: 15px;
    font-weight: 600;
    color: var(--cwp-msg-bot-text);
    margin-bottom: 14px;
    line-height: 1.4;
}
#cwp-widget-root .cwp-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#cwp-widget-root .cwp-suggestion-btn {
    font-family: var(--cwp-font);
    font-size: var(--cwp-suggestion-size, 13px);
    padding: 10px 14px;
    border: 1px solid var(--cwp-border);
    border-radius: 10px;
    background: var(--cwp-bg);
    color: var(--cwp-msg-bot-text);
    cursor: pointer;
    text-align: left;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: border-color 0.2s, background 0.2s;
}
#cwp-widget-root .cwp-suggestion-btn:hover {
    border-color: var(--cwp-primary);
    background: rgba(26, 86, 219, 0.05);
}

#cwp-widget-root .cwp-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 12px;
    font-family: var(--cwp-font);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
#cwp-widget-root .cwp-msg-user {
    align-self: flex-end;
    background: var(--cwp-msg-user);
    color: var(--cwp-msg-user-text);
    border-bottom-right-radius: 4px;
}
#cwp-widget-root .cwp-msg-bot {
    align-self: flex-start;
    background: var(--cwp-msg-bot);
    color: var(--cwp-msg-bot-text);
    border-bottom-left-radius: 4px;
}

#cwp-widget-root .cwp-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--cwp-msg-bot);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
#cwp-widget-root .cwp-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: cwpTyping 1.4s ease-in-out infinite;
}
#cwp-widget-root .cwp-typing-dot:nth-child(2) { animation-delay: 0.2s; }
#cwp-widget-root .cwp-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cwpTyping {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

#cwp-widget-root .cwp-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--cwp-border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    background: var(--cwp-bg);
}
#cwp-widget-root .cwp-input {
    flex: 1;
    font-family: var(--cwp-font);
    font-size: 16px;
    padding: 10px 14px;
    border: 1px solid var(--cwp-border);
    border-radius: 24px;
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
    color: var(--cwp-msg-bot-text);
    -webkit-appearance: none;
    appearance: none;
}
#cwp-widget-root .cwp-input:focus {
    border-color: var(--cwp-primary);
    background: var(--cwp-bg);
}
#cwp-widget-root .cwp-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--cwp-primary);
    color: var(--cwp-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}
#cwp-widget-root .cwp-send-btn:hover {
    background: var(--cwp-primary-hover);
}
#cwp-widget-root .cwp-send-btn:active {
    transform: scale(0.92);
}
#cwp-widget-root .cwp-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#cwp-widget-root .cwp-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

#cwp-widget-root .cwp-history-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--cwp-bg);
    z-index: 10;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
#cwp-widget-root .cwp-history-panel.cwp-panel-open {
    display: flex;
}
#cwp-widget-root .cwp-history-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--cwp-border);
    flex-shrink: 0;
}
#cwp-widget-root .cwp-history-back {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--cwp-msg-bot-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
#cwp-widget-root .cwp-history-back:hover {
    background: rgba(0,0,0,0.05);
}
#cwp-widget-root .cwp-history-back svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
#cwp-widget-root .cwp-history-title {
    font-family: var(--cwp-font);
    font-size: 14px;
    font-weight: 600;
    color: var(--cwp-msg-bot-text);
}
#cwp-widget-root .cwp-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}
#cwp-widget-root .cwp-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
    margin-bottom: 4px;
}
#cwp-widget-root .cwp-history-item:hover {
    background: rgba(0,0,0,0.04);
}
#cwp-widget-root .cwp-history-item.cwp-history-active {
    border-left-color: var(--cwp-primary);
    background: rgba(26, 86, 219, 0.06);
}
#cwp-widget-root .cwp-history-item-content {
    flex: 1;
    min-width: 0;
}
#cwp-widget-root .cwp-history-item-preview {
    font-family: var(--cwp-font);
    font-size: 13px;
    color: var(--cwp-msg-bot-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
#cwp-widget-root .cwp-history-item-date {
    font-family: var(--cwp-font);
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
    line-height: 1.3;
}
#cwp-widget-root .cwp-history-item-delete {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
#cwp-widget-root .cwp-history-item:hover .cwp-history-item-delete {
    opacity: 1;
}
#cwp-widget-root .cwp-history-item-delete:hover {
    color: #ef4444;
}
#cwp-widget-root .cwp-history-item-delete svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
#cwp-widget-root .cwp-history-empty {
    text-align: center;
    padding: 40px 20px;
    font-family: var(--cwp-font);
    font-size: 13px;
    color: #9ca3af;
}

@media (max-width: 480px) {
    #cwp-widget-root .cwp-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        border-radius: 12px;
        left: 12px !important;
        right: 12px !important;
        bottom: 12px !important;
        top: auto !important;
    }
}

#cwp-widget-root .cwp-powered-by {
    text-align: center;
    padding: 6px 12px;
    font-family: var(--cwp-font);
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
    border-top: 1px solid var(--cwp-border);
    background: var(--cwp-bg);
}
#cwp-widget-root .cwp-powered-by a {
    color: var(--cwp-primary);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.15s;
}
#cwp-widget-root .cwp-powered-by a:hover {
    opacity: 0.7;
}

#cwp-widget-root .cwp-msg a {
    color: var(--cwp-link, #2563eb);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    word-break: break-all;
    transition: opacity 0.15s;
}
#cwp-widget-root .cwp-msg a:hover {
    opacity: 0.75;
}
#cwp-widget-root .cwp-msg-user a {
    color: var(--cwp-msg-user-text);
    opacity: 0.9;
}
#cwp-widget-root .cwp-link-card {
    margin-top: 8px;
    border: 1px solid #d1d5db;
    border-left: 3px solid var(--cwp-link, #2563eb);
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s, transform 0.15s;
}
#cwp-widget-root .cwp-link-cards {
    margin-top: 6px;
    margin-bottom: 4px;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
}
#cwp-widget-root .cwp-link-cards .cwp-link-card:first-child {
    margin-top: 0;
}
#cwp-widget-root .cwp-link-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}
#cwp-widget-root .cwp-link-loading {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cwp-bg);
}
#cwp-widget-root .cwp-link-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--cwp-border);
    border-top-color: var(--cwp-primary);
    border-radius: 50%;
    animation: cwpSpin 0.7s linear infinite;
}
@keyframes cwpSpin {
    to { transform: rotate(360deg); }
}
#cwp-widget-root .cwp-link-card-image {
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: linear-gradient(135deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: cwpShimmer 1.5s infinite;
}
#cwp-widget-root .cwp-link-card-image img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}
@keyframes cwpShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
#cwp-widget-root .cwp-link-card-body {
    padding: 10px 14px 12px;
}
#cwp-widget-root .cwp-link-card-title {
    font-family: var(--cwp-font);
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#cwp-widget-root .cwp-link-card-desc {
    font-family: var(--cwp-font);
    font-size: 12px;
    color: #4b5563;
    margin-top: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
#cwp-widget-root .cwp-link-card-domain {
    font-family: var(--cwp-font);
    font-size: 11px;
    color: #6b7280;
    margin-top: 6px;
    text-transform: lowercase;
    display: flex;
    align-items: center;
    gap: 4px;
}
#cwp-widget-root .cwp-link-card-domain::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background: #e5e7eb;
    border-radius: 50%;
}
}
