.daic-chat {
    --daic-ink: #0b1220;
    --daic-panel: rgba(247, 248, 250, 0.96);
    --daic-red: #b40000;
    --daic-red-dark: #810000;
    --daic-teal: #147c73;
    --daic-line: rgba(255, 255, 255, 0.18);
    bottom: var(--daic-offset-y, 22px);
    color: #18212a;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    position: fixed;
    right: var(--daic-offset-x, 22px);
    z-index: 99999;
}

.daic-chat[data-position="left"] {
    left: var(--daic-offset-x, 22px);
    right: auto;
}

.daic-chat * {
    box-sizing: border-box;
}

.daic-chat__toggle {
    align-items: center;
    background: var(--daic-toggle-bg, rgba(11, 18, 32, 0.92));
    border: 1px solid var(--daic-toggle-border, rgba(255, 255, 255, 0.32));
    border-radius: var(--daic-toggle-radius, 999px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
    color: var(--daic-toggle-text, #ffffff);
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: var(--daic-toggle-font-size, 14px);
    font-weight: 900;
    height: var(--daic-toggle-height, 46px);
    justify-content: center;
    letter-spacing: 0;
    padding: 0 16px;
    width: auto;
}

.daic-chat__toggle-icon {
    line-height: 1;
    white-space: nowrap;
}

.daic-chat__panel {
    backdrop-filter: blur(16px);
    background: var(--daic-panel);
    border: 1px solid rgba(255, 255, 255, 0.54);
    border-radius: 8px;
    bottom: 78px;
    box-shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    right: 0;
    width: min(var(--daic-panel-width, 400px), calc(100vw - 32px));
    height: min(var(--daic-panel-height, 520px), calc(100vh - 112px));
}

.daic-chat[data-position="left"] .daic-chat__panel {
    left: 0;
    right: auto;
}

.daic-chat.is-quoting .daic-chat__messages {
    display: none;
}

.daic-chat.is-quoting .daic-chat__form {
    display: none;
}

.daic-chat.is-quoting .daic-chat__panel {
    overflow-y: auto;
}

.daic-chat__panel[hidden] {
    display: none;
}

.daic-chat__header {
    align-items: center;
    background: linear-gradient(135deg, #0b1220 0%, #131d2c 70%, #1b2636 100%);
    border-bottom: 2px solid var(--daic-accent, var(--daic-red));
    color: #ffffff;
    display: grid;
    grid-template-columns: 34px 1fr auto 34px;
    gap: 10px;
    padding: 14px 16px;
}

.daic-chat__mark {
    align-items: center;
    background: var(--daic-accent, var(--daic-red));
    border-radius: 6px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
    display: flex;
    font-size: 12px;
    font-weight: 900;
    height: 34px;
    justify-content: center;
    letter-spacing: 0;
    width: 34px;
}

.daic-chat__header strong,
.daic-chat__header span {
    display: block;
    line-height: 1.15;
}

.daic-chat__header strong {
    font-size: 22px;
    font-weight: 900;
}

.daic-chat__header div > span {
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
    margin-top: 5px;
}

.daic-chat__lang {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    display: flex;
    gap: 3px;
    padding: 3px;
}

.daic-chat__lang button {
    background: transparent;
    border: 0;
    border-radius: 5px;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    height: 28px;
    letter-spacing: 0;
    padding: 0 8px;
}

.daic-chat__lang button.is-active {
    background: var(--daic-accent, var(--daic-red));
    color: #ffffff;
}

.daic-chat__close {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 28px;
    height: 34px;
    justify-content: center;
    line-height: 1;
    padding: 0 0 3px;
    width: 34px;
}

.daic-chat__messages {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 246, 249, 0.94)),
        radial-gradient(circle at top right, rgba(180, 0, 0, 0.08), transparent 36%);
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    min-height: 185px;
    overflow-y: auto;
    padding: 18px 16px;
}

.daic-chat__actions {
    background: #ffffff;
    border-top: 1px solid rgba(11, 18, 32, 0.08);
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-end;
    padding: 10px 16px;
}

.daic-chat__actions a {
    align-items: center;
    background: #f8fafc;
    border: 1px solid rgba(11, 18, 32, 0.14);
    border-radius: 999px;
    color: #111827;
    display: inline-flex;
    font-size: 13px;
    font-weight: 900;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    text-decoration: none;
}

.daic-chat__message {
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(11, 18, 32, 0.08);
    font-size: 14px;
    line-height: 1.45;
    max-width: 88%;
    overflow-wrap: anywhere;
    padding: 11px 13px;
    white-space: pre-wrap;
}

.daic-chat__message--assistant {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid rgba(11, 18, 32, 0.09);
}

.daic-chat__message--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--daic-teal), #0c665f);
    color: #ffffff;
}

.daic-chat__lead {
    background: #ffffff;
    border-top: 1px solid rgba(11, 18, 32, 0.08);
    flex: 0 0 auto;
    max-height: 58%;
    overflow: hidden;
}

.daic-chat__lead[open] {
    border-top: 2px solid rgba(180, 0, 0, 0.2);
}

.daic-chat.is-quoting .daic-chat__lead[open] {
    display: block;
    flex: 0 0 auto;
    max-height: none;
    min-height: auto;
    overflow: visible;
}

.daic-chat__lead summary {
    align-items: center;
    color: #111827;
    cursor: pointer;
    display: flex;
    font-size: 14px;
    font-weight: 900;
    gap: 7px;
    list-style-position: inside;
    padding: 11px 16px;
}

.daic-chat__lead summary span + span {
    color: var(--daic-accent, var(--daic-red-dark));
}

.daic-chat__lead-form {
    display: grid;
    gap: 10px;
    max-height: min(360px, 42vh);
    min-height: auto;
    overflow-y: auto;
    padding: 0 14px 14px;
}

.daic-chat.is-quoting .daic-chat__lead-form {
    max-height: none;
    overflow: visible;
}

.daic-chat.is-quoting .daic-chat__lead-form {
    padding-bottom: 18px;
}

.daic-chat.is-quoting .daic-chat__lead-form,
.daic-chat.is-quoting .daic-chat__lead-fields {
    max-height: none;
    overflow: visible;
}

.daic-chat__lead-fields {
    display: grid;
    gap: 8px;
    min-height: auto;
    overflow-y: auto;
    padding-bottom: 10px;
    scrollbar-gutter: stable;
}

.daic-chat.is-quoting .daic-chat__lead-fields {
    padding-bottom: 2px;
}

.daic-chat__lead-form input,
.daic-chat__lead-form select,
.daic-chat__lead-form textarea {
    background: #fbfcfd;
    border: 1px solid rgba(11, 18, 32, 0.16);
    border-radius: 8px;
    box-shadow: none;
    color: #111827;
    font: inherit;
    font-size: 13px;
    min-height: 38px;
    padding: 8px 10px;
    width: 100%;
}

.daic-chat__lead-form textarea {
    line-height: 1.35;
    resize: vertical;
}

.daic-chat__consent {
    align-items: flex-start;
    color: #4b5563;
    display: flex;
    font-size: 12px;
    gap: 8px;
    line-height: 1.35;
}

.daic-chat__consent input {
    flex: 0 0 auto;
    min-height: auto;
    width: auto;
}

.daic-chat__lead-form button {
    background: var(--daic-send-bg, linear-gradient(135deg, var(--daic-red), var(--daic-red-dark)));
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(129, 0, 0, 0.18);
    min-height: 44px;
    width: 100%;
}

.daic-chat__lead-status {
    flex: 0 0 auto;
    color: var(--daic-teal);
    font-size: 12px;
    line-height: 1.35;
    margin: 0;
}

.daic-chat__form {
    align-items: flex-end;
    background: #ffffff;
    border-top: 1px solid rgba(11, 18, 32, 0.1);
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 76px;
    flex: 0 0 auto;
    padding: 12px;
}

.daic-chat__form textarea {
    background: #fbfcfd;
    border: 1px solid rgba(11, 18, 32, 0.16);
    border-radius: 8px;
    box-shadow: inset 0 1px 2px rgba(11, 18, 32, 0.04);
    color: #111827;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 110px;
    min-height: 46px;
    padding: 12px;
    resize: none;
}

.daic-chat__form textarea::placeholder {
    color: #8b95a5;
}

.daic-chat__form button {
    background: var(--daic-send-bg, linear-gradient(135deg, var(--daic-red), var(--daic-red-dark)));
    border: 0;
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(129, 0, 0, 0.2);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    min-height: 46px;
    padding: 0 12px;
}

.daic-chat.is-loading .daic-chat__form button {
    opacity: 0.68;
}

.daic-chat.is-loading .daic-chat__form button::after {
    content: "...";
}

@media (max-width: 520px) {
    .daic-chat {
        bottom: max(12px, var(--daic-offset-y, 12px));
        left: 12px;
        right: 12px;
    }

    .daic-chat__toggle {
        margin-left: auto;
    }

    .daic-chat__panel {
        bottom: 72px;
        height: min(620px, calc(100vh - 96px));
        left: 0;
        right: 0;
        width: 100%;
    }

    .daic-chat__messages {
        min-height: 110px;
    }

    .daic-chat__lead {
        max-height: 56%;
    }

    .daic-chat.is-quoting .daic-chat__lead[open] {
        max-height: none;
    }

    .daic-chat__header {
        grid-template-columns: 38px 1fr auto 38px;
        padding: 16px;
    }

    .daic-chat__mark {
        height: 38px;
        width: 38px;
    }

    .daic-chat__header strong {
        font-size: 21px;
    }

    .daic-chat__lang button {
        font-size: 10px;
        padding: 0 6px;
    }
}
