.tcn-chat-widget {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: 9999;
    font-family: "Dosis", sans-serif;
}

.tcn-chat-widget *,
.tcn-chat-widget *::before,
.tcn-chat-widget *::after {
    box-sizing: border-box;
}

.tcn-chat-widget__launcher {
    border: 0;
    border-radius: 999px;
    background: #007aff;
    color: #ffffff;
    padding: 12px 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
    font-size: 14px;
    line-height: 1.2;
}

.tcn-chat-widget__panel {
    width: min(360px, calc(100vw - 24px));
    height: min(560px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
}

.tcn-chat-widget__panel[hidden] {
    display: none;
}

.tcn-chat-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    background: linear-gradient(135deg, #007aff, #39a96b);
    color: #ffffff;
}

.tcn-chat-widget__title {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.tcn-chat-widget__status {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.4;
    opacity: 0.9;
}

.tcn-chat-widget__close {
    border: 0;
    background: transparent;
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.tcn-chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f9fc;
}

.tcn-chat-widget__message {
    max-width: 85%;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.tcn-chat-widget__message--assistant {
    background: #ffffff;
    color: #2b2f33;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tcn-chat-widget__message--user {
    margin-left: auto;
    background: #007aff;
    color: #ffffff;
    border-top-right-radius: 4px;
}

.tcn-chat-widget__message--system {
    max-width: 100%;
    font-size: 12px;
    text-align: center;
    background: rgba(0, 0, 0, 0.05);
    color: #5a6470;
}

.tcn-chat-widget__message--error {
    background: #fff3f1;
    color: #b6372e;
    border: 1px solid #ffd3ce;
}

.tcn-chat-widget__composer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    padding: 12px;
}

.tcn-chat-widget__error {
    min-height: 20px;
    font-size: 12px;
    color: #b6372e;
    margin-bottom: 8px;
}

.tcn-chat-widget__form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.tcn-chat-widget__actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.tcn-chat-widget__action {
    flex: 1 1 100%;
    min-height: 36px;
    border: 1px solid #007aff;
    border-radius: 10px;
    background: #eef5ff;
    color: #007aff;
    font-size: 13px;
    cursor: pointer;
}

.tcn-chat-widget__input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: vertical;
    border: 1px solid #d7dce2;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #2b2f33;
    outline: none;
}

.tcn-chat-widget__input:focus {
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.tcn-chat-widget__send {
    min-width: 76px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: #39a96b;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
}

.tcn-chat-widget__send[disabled],
.tcn-chat-widget__launcher[disabled],
.tcn-chat-widget__action[disabled] {
    cursor: not-allowed;
    opacity: 0.7;
}

.tcn-chat-widget__helper {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7480;
}

@media (max-width: 767px) {
    .tcn-chat-widget {
        right: 12px;
        bottom: 72px;
    }

    .tcn-chat-widget__panel {
        width: min(100vw - 24px, 360px);
        height: min(70vh, 520px);
    }

    .tcn-chat-widget__launcher {
        padding: 12px 18px;
    }
}
