.bsc-chat,
.bsc-chat * {
    box-sizing: border-box;
}

.bsc-chat button,
.bsc-chat textarea {
    width: auto;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
}

.bsc-chat {
    --bsc-accent: #0e4d6c;
    --bsc-send: #0e4d6c;
    --bsc-ink: #17313c;
    --bsc-muted: #5d727c;
    --bsc-bg: #ffffff;
    --bsc-soft: #f2f6f8;
    --bsc-line: #d7e2e8;
    --bsc-header: #0e3d52;
    --bsc-header-text: #f4fafb;
    --bsc-mine: #0e4d6c;
    --bsc-mine-text: #ffffff;
    --bsc-shadow: 0 16px 40px rgba(14, 40, 54, 0.18);
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 99990;
    font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
    color: var(--bsc-ink);
    font-size: 15px;
    line-height: 1.5;
}

.bsc-chat[data-site="roxy"] {
    --bsc-accent: #6f3b45;
    --bsc-send: #8a5a32;
    --bsc-ink: #2c211f;
    --bsc-muted: #7d6a64;
    --bsc-bg: #fffdfb;
    --bsc-soft: #f8f1ea;
    --bsc-line: #eadfd6;
    --bsc-header: #2a1c1e;
    --bsc-header-text: #fbf6ef;
    --bsc-mine: #6f3b45;
    --bsc-mine-text: #fffaf6;
    --bsc-shadow: 0 16px 40px rgba(42, 28, 30, 0.2);
}

.bsc-launcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: 0 18px 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--bsc-header);
    color: var(--bsc-header-text);
    box-shadow: var(--bsc-shadow);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.bsc-chat[data-site="roxy"] .bsc-launcher {
    box-shadow: var(--bsc-shadow), inset 0 0 0 1px rgba(181, 131, 74, 0.7);
}

.bsc-launcher:focus-visible,
.bsc-close:focus-visible,
.bsc-send:focus-visible,
.bsc-input:focus-visible {
    outline: 3px solid #d28a2e;
    outline-offset: 2px;
}

.bsc-launcher__icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
}

.bsc-launcher__icon svg {
    width: 28px;
    height: 28px;
    display: block;
}

.bsc-badge[hidden] {
    display: none !important;
}

.bsc-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #c2453d;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.bsc-panel {
    overscroll-behavior: contain;
    position: absolute;
    right: 0;
    bottom: 68px;
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 120px));
    background: var(--bsc-bg);
    color: var(--bsc-ink);
    border-radius: 18px;
    box-shadow: var(--bsc-shadow);
    overflow: hidden;
    border: 1px solid var(--bsc-line);
}

.bsc-panel[hidden] {
    display: none !important;
}

.bsc-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 14px 14px 16px;
    background: var(--bsc-header);
    color: var(--bsc-header-text);
}

.bsc-panel__head > div {
    min-width: 0;
    flex: 1 1 auto;
}

.bsc-kicker {
    margin: 0 0 4px;
    font-size: 12px;
    letter-spacing: 0.02em;
    opacity: 0.82;
}

.bsc-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.35;
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.bsc-chat .bsc-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.bsc-close:hover,
.bsc-launcher:hover {
    filter: brightness(1.08);
}

.bsc-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    background: var(--bsc-soft);
}

.bsc-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    margin: 0 0 10px;
}

.bsc-msg--in {
    align-self: flex-end;
    margin-left: auto;
}

.bsc-msg--out,
.bsc-msg--system {
    align-self: flex-start;
}

.bsc-msg__text {
    margin: 0;
    padding: 10px 12px;
    border-radius: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.bsc-msg--system .bsc-msg__text,
.bsc-msg--out .bsc-msg__text {
    background: #fff;
    border: 1px solid var(--bsc-line);
    border-bottom-left-radius: 4px;
}

.bsc-msg--in .bsc-msg__text {
    background: var(--bsc-mine);
    color: var(--bsc-mine-text);
    border-bottom-right-radius: 4px;
}

.bsc-msg__time {
    margin-top: 4px;
    color: var(--bsc-muted);
    font-size: 11px;
}

.bsc-msg--in .bsc-msg__time {
    text-align: right;
}

.bsc-form {
    position: relative;
    padding: 12px;
    background: var(--bsc-bg);
    border-top: 1px solid var(--bsc-line);
}

.bsc-chat .bsc-input {
    display: block;
    width: 100%;
    min-height: 72px;
    max-height: 140px;
    resize: vertical;
    box-sizing: border-box;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--bsc-line);
    border-radius: 12px;
    background: #fff;
    color: var(--bsc-ink);
    font: inherit;
    font-size: 16px;
    line-height: 1.45;
}

.bsc-form__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.bsc-count {
    color: var(--bsc-muted);
    font-size: 12px;
}

.bsc-chat .bsc-send {
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--bsc-send);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.bsc-chat .bsc-send:disabled {
    opacity: 0.55;
    cursor: default;
}

.bsc-status {
    min-height: 1.2em;
    margin: 8px 0 0;
    color: var(--bsc-muted);
    font-size: 12px;
}

.bsc-status.is-error {
    color: #9d2c2c;
}

.bsc-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.bsc-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 640px) {
    .bsc-chat {
        right: max(12px, env(safe-area-inset-right));
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .bsc-chat .bsc-launcher__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .bsc-chat .bsc-launcher {
        width: 58px;
        height: 58px;
        padding: 0;
        justify-content: center;
    }

    .bsc-chat .bsc-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(78px + env(safe-area-inset-bottom));
        width: auto;
        height: min(70vh, 640px);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .bsc-chat.is-open .bsc-panel {
        animation: bsc-rise 160ms ease-out;
    }
}

@keyframes bsc-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
