.ysc-chat {
    --ysc-bg: #FBF8F4;
    --ysc-site-bg: #F7F5F2;
    --ysc-warm: #F2ECE5;
    --ysc-title: #3A2F2A;
    --ysc-text: #6E625A;
    --ysc-muted: #8B6B58;
    --ysc-accent: #E86F1C;
    --ysc-accent-hover: #D45F10;
    --ysc-border: rgba(139, 107, 88, 0.22);
    --ysc-light: #FFFDF9;
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 99999;
    color: var(--ysc-text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.ysc-chat__launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 14px 22px;
    border: 1px solid var(--ysc-accent);
    border-radius: 999px;
    background: var(--ysc-accent);
    color: var(--ysc-light);
    box-shadow: 0 14px 30px rgba(58, 47, 42, 0.16);
    cursor: pointer;
    font: 600 15px/1 Inter, system-ui, sans-serif;
    letter-spacing: 0;
    transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

.ysc-chat__launcher:hover {
    background: var(--ysc-accent-hover);
    box-shadow: 0 16px 34px rgba(58, 47, 42, 0.2);
    transform: translateY(-1px);
}

.ysc-chat--open .ysc-chat__launcher {
    display: none;
}

.ysc-chat__launcher-icon {
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: relative;
}

.ysc-chat__launcher-icon::after {
    content: "";
    position: absolute;
    right: -2px;
    bottom: -4px;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(20deg);
}

.ysc-chat__panel {
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 32px));
    max-height: 620px;
    overflow: hidden;
    border: 1px solid var(--ysc-border);
    border-radius: 28px;
    background: var(--ysc-bg);
    box-shadow: 0 18px 42px rgba(58, 47, 42, 0.16);
}

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

.ysc-chat__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 16px;
    padding: 18px 20px 13px;
    background: var(--ysc-bg);
    border-bottom: 1px solid var(--ysc-border);
}

.ysc-chat__eyebrow {
    margin: 0 0 6px;
    color: var(--ysc-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.ysc-chat__header h2 {
    margin: 0;
    color: var(--ysc-title);
    font-family: "Playfair Display", Georgia, serif;
    font-size: 26px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0;
}

.ysc-chat__close {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--ysc-border);
    border-radius: 50%;
    background: var(--ysc-light);
    color: var(--ysc-title);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.ysc-chat__close:hover {
    background: var(--ysc-warm);
}

.ysc-chat__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.ysc-chat__intro {
    flex-shrink: 0;
    margin: 0;
    padding: 14px 18px 0;
    color: var(--ysc-text);
    font-size: 14px;
    line-height: 1.5;
}

.ysc-chat__quick {
    display: grid;
    flex-shrink: 0;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 18px 0;
}

.ysc-chat__quick button {
    min-height: 38px;
    border: 1px solid var(--ysc-border);
    border-radius: 16px;
    background: var(--ysc-light);
    color: var(--ysc-title);
    cursor: pointer;
    font: 600 13px/1.2 Inter, system-ui, sans-serif;
    text-decoration: none;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.ysc-chat__quick button:hover,
.ysc-chat__quick-active {
    background: var(--ysc-warm);
    border-color: rgba(139, 107, 88, 0.38);
    color: var(--ysc-title);
}

.ysc-chat__messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    min-height: 120px;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 14px 18px;
}

.ysc-chat--active .ysc-chat__messages {
    min-height: 0;
}

.ysc-chat__message {
    max-width: 78%;
    padding: 10px 12px;
    border: 1px solid rgba(139, 107, 88, 0.16);
    border-radius: 16px 16px 16px 4px;
    background: var(--ysc-light);
    color: var(--ysc-title);
    font-size: 14px;
    line-height: 1.45;
}

.ysc-chat__message p {
    margin: 0;
}

.ysc-chat__message-time {
    display: block;
    margin-top: 6px;
    color: rgba(110, 98, 90, 0.74);
    font-size: 12px;
    opacity: .75;
}

.ysc-chat__message--manager {
    align-self: flex-start;
    background: var(--ysc-warm);
    color: var(--ysc-title);
}

.ysc-chat__message--customer {
    align-self: flex-end;
    background: var(--ysc-accent);
    border-color: var(--ysc-accent);
    border-radius: 16px 16px 4px 16px;
    color: var(--ysc-light);
    font-size: 15px;
}

.ysc-chat__message--customer .ysc-chat__message-time {
    color: rgba(255, 253, 249, 0.78);
}

.ysc-chat__form {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    min-height: 0;
}

.ysc-chat__fields {
    display: grid;
    flex-shrink: 0;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 18px 10px;
}

.ysc-chat--active .ysc-chat__intro,
.ysc-chat--active .ysc-chat__quick,
.ysc-chat--active .ysc-chat__fields,
.ysc-chat--active .ysc-chat__privacy {
    display: none;
}

.ysc-chat label {
    display: grid;
    gap: 6px;
    color: var(--ysc-title);
    font-size: 13px;
    font-weight: 600;
}

.ysc-chat label small {
    color: var(--ysc-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.35;
}

.ysc-chat input,
.ysc-chat textarea {
    width: 100%;
    border: 1px solid var(--ysc-border);
    background: var(--ysc-light);
    color: var(--ysc-title);
    font: 500 15px/1.35 Inter, system-ui, sans-serif;
    outline: none;
}

.ysc-chat input {
    min-height: 44px;
    padding: 0 13px;
    border-radius: 18px;
}

.ysc-chat textarea {
    min-height: 44px;
    max-height: 96px;
    padding: 12px 14px;
    overflow-y: auto;
    resize: none;
    border-radius: 20px;
}

.ysc-chat input:focus,
.ysc-chat textarea:focus {
    border-color: rgba(232, 111, 28, 0.72);
    box-shadow: 0 0 0 3px rgba(232, 111, 28, 0.11);
}

.ysc-chat__hp {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.ysc-chat__privacy {
    flex-shrink: 0;
    margin: 0;
    padding: 0 18px 10px;
    color: rgba(110, 98, 90, 0.92);
    font-size: 12px;
    line-height: 1.45;
}

.ysc-chat__privacy a {
    color: var(--ysc-muted);
    text-decoration: none;
}

.ysc-chat__privacy a:hover {
    color: var(--ysc-title);
    text-decoration: none;
}

.ysc-chat__composer {
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 10px;
    padding: 12px 18px 10px;
    border-top: 1px solid rgba(139, 107, 88, 0.14);
    background: var(--ysc-bg);
}

.ysc-chat__message-field {
    flex: 1 1 auto;
    min-width: 0;
}

.ysc-chat__message-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.ysc-chat__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border: 1px solid var(--ysc-accent);
    border-radius: 50%;
    background: var(--ysc-accent);
    color: var(--ysc-light);
    cursor: pointer;
}

.ysc-chat__submit svg {
    width: 21px;
    height: 21px;
}

.ysc-chat__submit:hover {
    border-color: var(--ysc-accent-hover);
    background: var(--ysc-accent-hover);
}

.ysc-chat__submit:disabled {
    cursor: wait;
    opacity: .72;
}

.ysc-chat__status {
    min-height: 16px;
    margin: 0;
    padding: 0 18px 6px;
    color: var(--ysc-text);
    font-size: 13px;
    line-height: 1.35;
}

.ysc-chat__status--error {
    color: #9F2F1F;
}

.ysc-chat__footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 18px 12px;
    background: var(--ysc-bg);
    color: var(--ysc-muted);
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

.ysc-chat__footer::before {
    content: "Другие способы:";
    margin-right: 3px;
}

.ysc-chat__footer a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ysc-muted);
    font-size: 13px;
    text-decoration: none;
}

.ysc-chat__footer a + a::before {
    content: "·";
    margin: 0 8px 0 4px;
    color: rgba(139, 107, 88, 0.7);
}

.ysc-chat__footer a:hover {
    color: var(--ysc-title);
    text-decoration: none;
}

@media (max-width: 520px) {
    .ysc-chat {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        left: 12px;
    }

    .ysc-chat__launcher {
        margin-left: auto;
    }

    .ysc-chat__panel {
        width: calc(100vw - 24px);
        max-height: 82dvh;
        border-radius: 24px;
    }

    .ysc-chat__header {
        padding: 14px 18px 12px;
    }

    .ysc-chat__eyebrow {
        font-size: 12px;
    }

    .ysc-chat__header h2 {
        font-size: 24px;
    }

    .ysc-chat__fields,
    .ysc-chat__quick {
        grid-template-columns: 1fr;
    }

    .ysc-chat__messages {
        min-height: 96px;
        padding: 12px 18px;
    }

    .ysc-chat--active .ysc-chat__messages {
        min-height: 72px;
    }

    .ysc-chat__composer {
        padding: 10px 18px 8px;
    }

    .ysc-chat__footer {
        padding: 5px 18px 10px;
    }
}
