:root {
    /* #fccc26 */
    --tlc-primary: #24A1DE;
    --tlc-primary-hover: color-mix(in srgb, var(--tlc-primary) 90%, #000);
    --red: color-mix();
    --tlc-bg-light: #F3F4F6;
    --tlc-text-dark: #1F2937;
    --tlc-text-muted: #6B7280;
    --tlc-text-on-accent: #3A3A3A;
    --attention: #EF4444;
    --tlc-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.tlc-widget-container {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-sizing: border-box;
}

.tlc-widget-container * {
    box-sizing: border-box;
}

.tlc-pos-right {
    right: 24px;
}

.tlc-pos-left {
    left: 24px;
}

/* Floating Launcher Button */
.tlc-launcher-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--tlc-primary);
    color: var(--tlc-text-on-accent);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s;
    position: relative;
}

.tlc-launcher-btn:hover {
    transform: scale(1.08);
    background: var(--tlc-primary-hover);
}

.tlc-launcher-btn:active {
    transform: scale(0.95);
}

.tlc-launcher-btn svg {
    display: grid;
    align-items: center;
    align-content: center;
}

.tlc-unread-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: var(--attention);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    animation: tlc-pulse 2s infinite;
}

@keyframes tlc-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Chat Popup Modal */
.tlc-chat-modal {
    position: absolute;
    bottom: 76px;
    width: 370px;
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: var(--tlc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: tlc-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.tlc-pos-right .tlc-chat-modal {
    right: 0;
}

.tlc-pos-left .tlc-chat-modal {
    left: 0;
}

@keyframes tlc-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.tlc-chat-header {
    background: var(--tlc-primary);
    color: var(--tlc-text-on-accent);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
    z-index: 1;
}

.tlc-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tlc-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tlc-header-text {
    display: flex;
    flex-direction: column;
}

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

.tlc-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tlc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.tlc-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tlc-header-end {
    background: rgba(255, 255, 255, 0.4);
    border: none;
    color: var(--tlc-text-on-accent);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: opacity 0.2s, background 0.2s;
}

.tlc-header-end:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.8);
}

.tlc-header-close {
    background: none;
    border: none;
    color: var(--tlc-text-on-accent);
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tlc-header-close:hover {
    background: rgba(239, 68, 68, 0.8);
    opacity: 1;
}

/* Pre-chat Screen */
.tlc-prechat-screen {
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    background: #F9FAFB;
}

.tlc-prechat-intro {
    font-size: 14px;
    color: var(--tlc-text-dark);
    margin-bottom: 20px;
    text-align: center;
}

.tlc-form-group {
    margin-bottom: 14px;
}

.tlc-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

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

.tlc-btn-telegram {
    width: 100%;
    padding: 12px;
    background: #24A1DE;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.15s;
}

.tlc-btn-telegram:hover {
    background: #1c8abd;
    transform: translateY(-1px);
}

.tlc-btn-telegram svg {
    flex-shrink: 0;
}

.tlc-btn-start {
    width: 100%;
    padding: 12px;
    background: var(--tlc-primary);
    color: var(--tlc-text-on-accent);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s;
}

.tlc-btn-start:hover {
    background: var(--tlc-primary-hover);
}

/* Body / Messages */
.tlc-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #F9FAFB;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#tlc-messages-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tlc-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.tlc-msg-operator {
    align-self: flex-start;
}

.tlc-msg-visitor {
    align-self: flex-end;
}

.tlc-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
}

.tlc-msg-operator .tlc-msg-bubble {
    background: #ffffff;
    color: var(--tlc-text-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

.tlc-quote-box {
    border-left: 3px solid var(--tlc-primary);
    background: rgba(0, 0, 0, 0.04);
    padding: 5px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, transform 0.1s;
}

.tlc-quote-box:hover {
    background: rgba(0, 0, 0, 0.08);
}

.tlc-quote-box:active {
    transform: scale(0.98);
}

.tlc-quote-title {
    font-weight: 600;
    font-size: 11px;
    color: var(--tlc-primary);
    margin-bottom: 2px;
}

.tlc-quote-text {
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.tlc-highlight-pulse {
    animation: tlc-flash-highlight 1.5s ease-in-out;
}

@keyframes tlc-flash-highlight {
    0% {
        box-shadow: 0 0 0 0 rgba(36, 161, 222, 0.7);
    }
    35% {
        box-shadow: 0 0 0 6px rgba(36, 161, 222, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(36, 161, 222, 0.15);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(36, 161, 222, 0);
    }
}

.tlc-msg-time {
    display: block;
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

/* Footer / Input */
.tlc-chat-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #E5E7EB;
}

.tlc-chat-footer form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tlc-chat-footer textarea {
    flex: 1;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    min-height:64px;
    max-height: 106px;
    font-family: inherit;
}

.tlc-chat-footer textarea:focus {
    border-color: var(--tlc-primary);
}

.tlc-chat-footer button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--tlc-primary);
    color: var(--tlc-text-on-accent);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.tlc-chat-footer button:hover {
    background: var(--tlc-primary-hover);
}

@media (max-width: 480px) {
    .tlc-chat-modal {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 76px;
    }
}
