.page {
    padding-bottom: 32px;
}

.ss-chat {
    box-sizing: border-box;

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    [hidden] {
        display: none !important;
    }
}

.ss-chat__launcher {
    position: fixed;
    z-index: 1400;
    right: 20px;
    bottom: 20px;
    width: 58px;
    height: 58px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #0a0a0a;
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(10, 10, 10, .28), 0 2px 6px rgba(10, 10, 10, .16);
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;

    &:hover {
        background: #000;
        transform: translateY(-1px);
    }

    &:active {
        transform: translateY(0) scale(.98);
    }

    &:focus-visible {
        outline: 3px solid rgba(10, 10, 10, .35);
        outline-offset: 3px;
    }

    svg {
        display: block;
    }

    .ss-chat__icon-close {
        display: none;
    }

    &[aria-expanded="true"] {
        .ss-chat__icon-open {
            display: none;
        }

        .ss-chat__icon-close {
            display: block;
        }
    }
}

.ss-chat__panel {
    position: fixed;
    z-index: 1401;
    right: 20px;
    bottom: 92px;
    width: min(392px, calc(100vw - 32px));
    max-height: min(680px, calc(100dvh - 112px));
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid rgba(16, 24, 40, .08);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(16, 24, 40, .18), 0 2px 8px rgba(16, 24, 40, .06);
    overflow: hidden;
    transform-origin: bottom right;
    animation: ss-chat-in .18s ease;

    @media (max-width: 480px) {
        left: 12px;
        right: 12px;
        width: auto;
    }

    @media (prefers-reduced-motion: reduce) {
        animation: none;
    }
}

.ss-chat__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 14px 14px 16px;
    border-bottom: 1px solid #eef0f2;
    flex-shrink: 0;
}

.ss-chat__intro {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.ss-chat__mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #0a0a0a;
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.ss-chat__title {
    margin: 1px 0 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.2px;
    line-height: 1.2;
}

.ss-chat__subtitle {
    margin: 3px 0 0;
    color: #6b7177;
    font-size: 12.5px;
    line-height: 1.4;
}

.ss-chat__close {
    width: 32px;
    height: 32px;
    margin-top: -2px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #3d4248;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;

    &:hover {
        background: #f1f1f3;
    }

    &:focus-visible {
        outline: 2px solid #0a0a0a;
        outline-offset: 1px;
    }
}

.ss-chat__form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0;
}

.ss-chat__scroll {
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px 16px 18px;
    scrollbar-width: thin;
}

.ss-chat__actions {
    flex-shrink: 0;
    padding: 10px 16px 16px;
    border-top: 1px solid #eef0f2;
    background: #fff;
}

.ss-chat__success {
    overflow: auto;
    padding: 28px 22px 22px;
    scrollbar-width: thin;
}

.ss-chat__banner {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff4f2;
    color: #9f1c1c;
    font-size: 13px;
    line-height: 1.4;
}

.ss-chat__field + .ss-chat__field {
    margin-top: 12px;
}

.ss-chat__label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.ss-chat__field label {
    font-size: 13px;
    font-weight: 600;
    color: #303030;
}

.ss-chat__optional {
    font-size: 11px;
    font-weight: 500;
    color: #9097a0;
}

.ss-chat__field input,
.ss-chat__field textarea {
    width: 100%;
    border: 1px solid #e1e3e6;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    max-width: 100%;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: #1a1a1a;
    outline: none;
    transition: border-color .15s, box-shadow .15s;

    &::placeholder {
        color: #9aa0a6;
    }

    &:focus {
        border-color: #0a0a0a;
        box-shadow: 0 0 0 3px rgba(10, 10, 10, .08);
    }
}

.ss-chat__field textarea {
    min-height: 85px;
    max-height: 160px;
    resize: vertical;
}

.ss-chat__field.is-invalid {
    input,
    textarea,
    .ss-chat__drop-hit,
    .ss-chat__drop-preview {
        border-color: #ba1a1a;
    }

    input:focus,
    textarea:focus {
        box-shadow: 0 0 0 3px rgba(186, 26, 26, .12);
    }
}

.ss-chat__field-error {
    margin: 6px 0 0;
    color: #ba1a1a;
    font-size: 12px;
    line-height: 1.35;
}

.ss-chat__drop-hit {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1.5px dashed #d5d7db;
    border-radius: 12px;
    background: #fafafa;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s;

    &:hover {
        border-color: #0a0a0a;
        background: #fff;
    }
}

.ss-chat__drop.is-dragover .ss-chat__drop-hit {
    border-color: #0a0a0a;
    background: #fff;
}

.ss-chat__file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.ss-chat__drop-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fff;
    color: #0a0a0a;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.ss-chat__drop-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
}

.ss-chat__drop-hint {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #6b7177;
}

.ss-chat__drop-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid #e6e7eb;
    border-radius: 12px;
    background: #fff;

    img {
        width: 56px;
        height: 56px;
        object-fit: cover;
        border-radius: 8px;
        background: #f1f1f3;
        flex-shrink: 0;
    }
}

.ss-chat__file-meta {
    min-width: 0;
    flex: 1;
}

.ss-chat__file-name {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ss-chat__remove {
    margin-top: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: #6b7177;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;

    &:hover {
        color: #ba1a1a;
    }
}

.ss-chat__actions .btn,
.ss-chat__success .btn {
    width: 100%;
    margin-top: 0;
    border: 0;
    border-radius: 10px;
    padding: 12px 16px;
    background: #0a0a0a;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;

    &:hover:not(:disabled) {
        background: #000;
    }

    &:disabled {
        opacity: .5;
        cursor: default;
    }
}

.ss-chat__success .btn {
    margin-top: 14px;
}

.ss-chat__success {
    text-align: center;
}

.ss-chat__success-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #e7f6ef;
    color: #007755;
    display: grid;
    place-items: center;
}

.ss-chat__success h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.ss-chat__success p {
    margin: 6px 0 0;
    color: #6b7177;
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.ss-chat__hp {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;

    input,
    label {
        width: 1px;
        height: 1px;
        margin: 0;
        padding: 0;
        border: 0;
    }
}

@keyframes ss-chat-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media print {
    .ss-chat__launcher,
    .ss-chat__panel {
        display: none !important;
    }
}
