/* ============================================
   Chat Widget Design System
   Intercom-style customer-facing chat widget
   ============================================ */

:root {
    --cw-primary: #6366F1;
    --cw-primary-dark: #4F46E5;
    --cw-primary-light: #818CF8;
    --cw-on-primary: #FFFFFF;

    --cw-surface: #FFFFFF;
    --cw-surface-dim: #F9FAFB;
    --cw-surface-container: #F3F4F6;
    --cw-on-surface: #111827;
    --cw-on-surface-secondary: #6B7280;

    --cw-outline: #E5E7EB;
    --cw-outline-dim: #F3F4F6;

    --cw-error: #EF4444;
    --cw-success: #22C55E;
    --cw-warning: #F59E0B;

    --cw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --cw-radius-sm: 8px;
    --cw-radius-md: 12px;
    --cw-radius-lg: 16px;
    --cw-radius-xl: 20px;
    --cw-radius-full: 9999px;

    --cw-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    --cw-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--cw-font);
    color: var(--cw-on-surface);
    background: #F0F2F5;
    min-height: 100vh;
}

/* --- Simulated website background --- */
.cw-website-bg {
    min-height: 100vh;
    background: #F0F2F5;
    padding: 40px;
}

.cw-website-placeholder {
    max-width: 800px;
    margin: 0 auto;
}

.cw-website-placeholder h1 {
    font-size: 28px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 16px;
}

.cw-website-placeholder p {
    font-size: 16px;
    line-height: 1.6;
    color: #6B7280;
    margin-bottom: 12px;
}

.cw-website-placeholder .cw-placeholder-card {
    background: white;
    border-radius: var(--cw-radius-md);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--cw-shadow-sm);
}

/* --- Launcher Button --- */
.cw-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-primary);
    color: var(--cw-on-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    z-index: 1000;
    transition: transform 0.15s ease;
}

.cw-launcher:hover { transform: scale(1.05); }
.cw-launcher:active { transform: scale(0.95); }
.cw-launcher svg { width: 28px; height: 28px; }

.cw-launcher-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-error);
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
}

/* --- Widget Frame --- */
.cw-widget {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 600px;
    border-radius: var(--cw-radius-xl);
    background: var(--cw-surface);
    box-shadow: var(--cw-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
}

/* --- Header --- */
.cw-header {
    background: linear-gradient(135deg, var(--cw-primary) 0%, var(--cw-primary-dark) 100%);
    color: var(--cw-on-primary);
    padding: 20px 20px 16px;
    flex-shrink: 0;
}

.cw-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.cw-header-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
}

.cw-header-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: var(--cw-radius-full);
    cursor: pointer;
    color: var(--cw-on-primary);
}

.cw-header-close svg { width: 18px; height: 18px; }

.cw-header-subtitle {
    font-size: 13px;
    line-height: 18px;
    opacity: 0.85;
    margin-bottom: 12px;
}

.cw-header-back {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--cw-on-primary);
    margin-left: -4px;
    margin-right: 8px;
}

.cw-header-back svg { width: 20px; height: 20px; }

/* Team avatars row */
.cw-team-avatars {
    display: flex;
    gap: 0;
}

.cw-team-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--cw-radius-full);
    background: rgba(255,255,255,0.25);
    color: var(--cw-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid var(--cw-primary);
    margin-left: -8px;
    position: relative;
}

.cw-team-avatar:first-child { margin-left: 0; }

.cw-team-avatar img,
.cw-conversation-avatar img,
.cw-msg-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.cw-team-avatar-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-success);
    border: 2px solid var(--cw-primary);
}

/* --- Content area --- */
.cw-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* --- Greeting card --- */
.cw-greeting-card {
    background: var(--cw-surface);
    border: 1px solid var(--cw-outline);
    border-radius: var(--cw-radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.cw-greeting-text {
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    margin-bottom: 16px;
}

.cw-greeting-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-primary);
    color: var(--cw-on-primary);
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--cw-font);
    cursor: pointer;
    text-decoration: none;
}

.cw-greeting-btn:hover { background: var(--cw-primary-dark); }
.cw-greeting-btn svg { width: 18px; height: 18px; }

/* --- Conversation list items --- */
.cw-section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--cw-on-surface-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.cw-conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--cw-radius-md);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    margin-bottom: 4px;
}

.cw-conversation-item:hover { background: var(--cw-surface-dim); }

.cw-conversation-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-surface-container);
    color: var(--cw-on-surface-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.cw-conversation-body {
    flex: 1;
    min-width: 0;
}

.cw-conversation-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.cw-conversation-preview {
    font-size: 13px;
    line-height: 18px;
    color: var(--cw-on-surface-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cw-conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.cw-conversation-time {
    font-size: 12px;
    color: var(--cw-on-surface-secondary);
}

.cw-conversation-badge {
    min-width: 20px;
    height: 20px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* --- Search bar --- */
.cw-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--cw-radius-md);
    background: var(--cw-surface-container);
    margin-bottom: 16px;
}

.cw-search svg {
    width: 18px;
    height: 18px;
    color: var(--cw-on-surface-secondary);
    flex-shrink: 0;
}

.cw-search-text {
    font-size: 14px;
    color: var(--cw-on-surface-secondary);
}

/* --- Powered by footer --- */
.cw-powered-by {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--cw-on-surface-secondary);
    flex-shrink: 0;
    border-top: 1px solid var(--cw-outline-dim);
}

.cw-powered-by a {
    color: var(--cw-on-surface);
    font-weight: 600;
    text-decoration: none;
}

.cw-powered-by a:hover {
    text-decoration: underline;
}

/* --- Messages --- */
.cw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cw-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
}

.cw-msg-row--visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cw-msg-row--agent {
    align-self: flex-start;
}

.cw-msg-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-surface-container);
    color: var(--cw-on-surface-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.cw-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--cw-radius-lg);
    font-size: 14px;
    line-height: 20px;
}

.cw-msg-bubble--visitor {
    background: var(--cw-primary);
    color: var(--cw-on-primary);
    border-bottom-right-radius: 4px;
}

.cw-msg-bubble--agent {
    background: var(--cw-surface-container);
    color: var(--cw-on-surface);
    border-bottom-left-radius: 4px;
}

.cw-msg-time {
    font-size: 11px;
    color: var(--cw-on-surface-secondary);
    padding: 2px 8px;
}

.cw-msg-time--visitor {
    text-align: right;
}

.cw-msg-time--agent {
    text-align: left;
    padding-left: 44px;
}

/* Typing indicator */
.cw-typing {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
}

.cw-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--cw-surface-container);
    border-radius: var(--cw-radius-lg);
    border-bottom-left-radius: 4px;
}

.cw-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-on-surface-secondary);
    opacity: 0.4;
    animation: cw-typing-bounce 1.4s ease-in-out infinite;
}

.cw-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cw-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cw-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 0.8; }
}

/* --- Composer --- */
.cw-composer {
    border-top: 1px solid var(--cw-outline);
    padding: 8px 12px 12px;
    flex-shrink: 0;
    background: var(--cw-surface);
}

.cw-composer-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cw-composer-input {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 8px 8px 14px;
    border: 1px solid var(--cw-outline);
    border-radius: var(--cw-radius-full);
    background: var(--cw-surface);
    min-height: 40px;
    font-size: 14px;
    color: var(--cw-on-surface-secondary);
}

.cw-composer-input-text {
    flex: 1;
    min-width: 0;
}

.cw-composer-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--cw-radius-full);
    cursor: pointer;
    color: var(--cw-on-surface-secondary);
}

.cw-composer-btn svg { width: 18px; height: 18px; }

.cw-composer-send {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-primary);
    color: var(--cw-on-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cw-composer-send svg { width: 16px; height: 16px; }

/* --- Form styles --- */
.cw-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.cw-form-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
}

.cw-form-description {
    font-size: 14px;
    line-height: 20px;
    color: var(--cw-on-surface-secondary);
}

.cw-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cw-form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--cw-on-surface);
}

.cw-form-input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--cw-outline);
    border-radius: var(--cw-radius-sm);
    font-size: 14px;
    font-family: var(--cw-font);
    color: var(--cw-on-surface);
    background: var(--cw-surface);
    outline: none;
}

.cw-form-input:focus { border-color: var(--cw-primary); }

.cw-form-textarea {
    padding: 10px 12px;
    border: 1px solid var(--cw-outline);
    border-radius: var(--cw-radius-sm);
    font-size: 14px;
    font-family: var(--cw-font);
    color: var(--cw-on-surface);
    background: var(--cw-surface);
    resize: vertical;
    min-height: 80px;
    outline: none;
}

.cw-form-textarea:focus { border-color: var(--cw-primary); }

.cw-form-submit {
    height: 44px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-primary);
    color: var(--cw-on-primary);
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--cw-font);
    cursor: pointer;
}

.cw-form-submit:hover { background: var(--cw-primary-dark); }

/* --- Offline banner --- */
.cw-offline-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--cw-surface-dim);
    border-radius: var(--cw-radius-md);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--cw-on-surface-secondary);
}

.cw-offline-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--cw-warning);
}

/* --- Header compact (for chat/form views) --- */
.cw-header--compact {
    padding: 12px 12px 12px 8px;
}

.cw-header--compact .cw-header-row {
    margin-bottom: 0;
}

.cw-header-center {
    flex: 1;
    min-width: 0;
}

.cw-header-center-title {
    font-size: 15px;
    font-weight: 600;
}

.cw-header-center-sub {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cw-header-online-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-success);
    flex-shrink: 0;
}

/* --- Divider --- */
.cw-divider {
    height: 1px;
    background: var(--cw-outline-dim);
    margin: 8px 0;
}

/* --- Index page styles --- */
.cw-index {
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 24px;
}

.cw-index h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cw-index p {
    font-size: 14px;
    color: var(--cw-on-surface-secondary);
    margin-bottom: 24px;
}

.cw-index-section {
    font-size: 12px;
    font-weight: 600;
    color: var(--cw-on-surface-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    margin-top: 20px;
}

.cw-index a {
    display: block;
    padding: 14px 16px;
    border-radius: var(--cw-radius-md);
    text-decoration: none;
    color: var(--cw-on-surface);
    border: 1px solid var(--cw-outline);
    margin-bottom: 8px;
    transition: background 0.1s;
}

.cw-index a:hover { background: var(--cw-surface-dim); }

.cw-index a .cw-index-title {
    font-size: 15px;
    font-weight: 500;
}

.cw-index a .cw-index-desc {
    font-size: 13px;
    color: var(--cw-on-surface-secondary);
    margin-top: 2px;
}

/* --- Header muted (offline) --- */
.cw-header--muted {
    background: linear-gradient(135deg, #6B7280 0%, #4B5563 100%);
}

/* --- Page navigation in website background --- */
.cw-page-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cw-page-nav-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.cw-page-nav-link {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: var(--cw-primary);
    border-radius: var(--cw-radius-sm);
}

.cw-page-nav-link:hover {
    background: rgba(99, 102, 241, 0.08);
}

.cw-page-nav-link--active {
    color: #374151;
    font-weight: 600;
}

/* --- Theme switcher --- */
.cw-theme-switcher {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #E5E7EB;
}

.cw-theme-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.cw-theme-select {
    padding: 6px 8px;
    font-size: 13px;
    font-family: var(--cw-font);
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: white;
    color: #374151;
    cursor: pointer;
    outline: none;
}

.cw-theme-select:focus {
    border-color: #6366F1;
}

/* --- Tab bar --- */
.cw-tab-bar {
    display: flex;
    border-top: 1px solid var(--cw-outline);
    flex-shrink: 0;
    background: var(--cw-surface);
}

.cw-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 10px;
    text-decoration: none;
    color: var(--cw-on-surface-secondary);
    font-size: 11px;
    font-weight: 500;
    transition: color 0.15s;
}

.cw-tab svg {
    width: 22px;
    height: 22px;
}

.cw-tab:hover {
    color: var(--cw-on-surface);
}

.cw-tab--active {
    color: var(--cw-primary);
}

.cw-tab--active:hover {
    color: var(--cw-primary);
}

/* --- Help page --- */
.cw-help-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--cw-radius-md);
    text-decoration: none;
    color: var(--cw-on-surface);
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

.cw-help-item:hover {
    background: var(--cw-surface-dim);
}

.cw-help-item svg {
    width: 18px;
    height: 18px;
    color: var(--cw-on-surface-secondary);
    flex-shrink: 0;
}

.cw-help-collection {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--cw-radius-md);
    text-decoration: none;
    color: var(--cw-on-surface);
}

.cw-help-collection:hover {
    background: var(--cw-surface-dim);
}

.cw-help-collection-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--cw-radius-md);
    background: var(--cw-surface-container);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cw-help-collection-icon svg {
    width: 20px;
    height: 20px;
    color: var(--cw-primary);
}

.cw-help-collection-body {
    flex: 1;
    min-width: 0;
}

.cw-help-collection-name {
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

.cw-help-collection-count {
    font-size: 12px;
    color: var(--cw-on-surface-secondary);
}

.cw-help-collection-arrow {
    width: 16px;
    height: 16px;
    color: var(--cw-on-surface-secondary);
    flex-shrink: 0;
}

/* --- Bot avatar --- */
.cw-msg-avatar--bot {
    background: var(--cw-primary-light);
    color: white;
}

.cw-msg-avatar--bot svg {
    width: 16px;
    height: 16px;
}

/* --- Sparkle icon (header + inline) --- */
.cw-sparkle-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    opacity: 0.9;
}

.cw-sparkle-inline {
    width: 10px;
    height: 10px;
    vertical-align: -1px;
    color: var(--cw-primary);
}

/* --- System message (handoff) --- */
.cw-msg-system {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    margin: 8px 0;
    font-size: 12px;
    color: var(--cw-on-surface-secondary);
    text-align: center;
}

.cw-msg-system svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.cw-msg-system strong {
    font-weight: 600;
    color: var(--cw-on-surface);
}

/* --- Inline article cards in chat --- */
.cw-msg-articles {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 0 0 36px;
    margin-bottom: 4px;
}

.cw-msg-article-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--cw-surface);
    border: 1px solid var(--cw-outline);
    border-radius: var(--cw-radius-md);
    text-decoration: none;
    color: var(--cw-on-surface);
}

.cw-msg-article-card:hover {
    background: var(--cw-surface-dim);
}

.cw-msg-article-card > svg {
    width: 18px;
    height: 18px;
    color: var(--cw-primary);
    flex-shrink: 0;
}

.cw-msg-article-body {
    flex: 1;
    min-width: 0;
}

.cw-msg-article-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
}

.cw-msg-article-desc {
    font-size: 12px;
    line-height: 16px;
    color: var(--cw-on-surface-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cw-msg-article-arrow {
    width: 14px;
    height: 14px;
    color: var(--cw-on-surface-secondary);
    flex-shrink: 0;
}

/* --- Trigger bubble --- */
.cw-trigger {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 1000;
}

.cw-trigger-body {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--cw-surface);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow);
    max-width: 300px;
    text-decoration: none;
    color: var(--cw-on-surface);
    cursor: pointer;
}

.cw-trigger-body:hover {
    background: var(--cw-surface-dim);
}

.cw-trigger-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-surface-container);
    overflow: hidden;
    flex-shrink: 0;
}

.cw-trigger-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cw-trigger-text {
    font-size: 14px;
    line-height: 20px;
    color: var(--cw-on-surface);
}

.cw-trigger-text strong {
    font-weight: 600;
}

.cw-trigger-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: var(--cw-radius-full);
    background: var(--cw-surface);
    border: 1px solid var(--cw-outline);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--cw-on-surface-secondary);
    box-shadow: var(--cw-shadow-sm);
    padding: 0;
}

.cw-trigger-close svg {
    width: 14px;
    height: 14px;
}

.cw-trigger-close:hover {
    background: var(--cw-surface-dim);
}

.cw-trigger-tail {
    width: 12px;
    height: 12px;
    background: var(--cw-surface);
    position: absolute;
    bottom: -6px;
    right: 28px;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
}

/* --- Expanded widget (article view) --- */
.cw-widget--expanded {
    width: 480px;
    height: 720px;
}

/* --- Article content --- */
.cw-article {
    padding: 4px 0;
}

.cw-article h1 {
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
    margin-bottom: 12px;
    color: var(--cw-on-surface);
}

.cw-article h2 {
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--cw-on-surface);
}

.cw-article h3 {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    margin-top: 16px;
    margin-bottom: 6px;
    color: var(--cw-on-surface);
}

.cw-article p {
    font-size: 14px;
    line-height: 22px;
    color: #374151;
    margin-bottom: 12px;
}

.cw-article img {
    width: 100%;
    border-radius: var(--cw-radius-md);
    margin: 8px 0 16px;
}

.cw-article ul,
.cw-article ol {
    font-size: 14px;
    line-height: 22px;
    color: #374151;
    margin-bottom: 12px;
    padding-left: 20px;
}

.cw-article li {
    margin-bottom: 4px;
}

.cw-article blockquote {
    border-left: 3px solid var(--cw-primary-light);
    padding: 10px 16px;
    margin: 12px 0;
    background: var(--cw-surface-dim);
    border-radius: 0 var(--cw-radius-sm) var(--cw-radius-sm) 0;
    font-size: 14px;
    line-height: 22px;
    color: #374151;
}

.cw-article strong {
    font-weight: 600;
    color: var(--cw-on-surface);
}
