.nsc-widget,
.nsc-widget * { box-sizing: border-box; }

.nsc-widget {
    --nsc-brand: #d71920;
    --nsc-brand-dark: #b8141a;
    --nsc-green: #2f8f36;
    --nsc-text: #1f2933;
    --nsc-muted: #687586;
    --nsc-line: #e3e9ef;
    --nsc-soft: #f6f8fa;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 99990;
    color: var(--nsc-text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

.nsc-widget__launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(var(--nsc-launcher-offset, 0px));
    transition: transform .2s ease;
}

.nsc-widget__launcher-label {
    padding: 10px 13px;
    border: 1px solid var(--nsc-line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(24, 38, 56, .12);
    font-weight: 700;
}

.nsc-widget__launcher-button {
    position: relative;
    display: grid;
    width: 60px;
    height: 60px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: var(--nsc-brand);
    box-shadow: 0 12px 30px rgba(183, 20, 26, .3);
    cursor: pointer;
}

.nsc-widget__launcher-button::before {
    content: "";
    width: 26px;
    height: 20px;
    border: 2px solid currentColor;
    border-radius: 7px;
}

.nsc-widget__badge {
    position: absolute;
    top: -2px;
    right: -1px;
    display: none;
    min-width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: var(--nsc-green);
    font-size: 10px;
    font-weight: 800;
}

.nsc-widget__badge.is-visible { display: flex; }

.nsc-widget__panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    width: min(408px, calc(100vw - 32px));
    height: min(650px, calc(100vh - 120px));
    min-height: 480px;
    overflow: hidden;
    border: 1px solid var(--nsc-line);
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(24, 38, 56, .2), 0 4px 16px rgba(24, 38, 56, .08);
    opacity: 0;
    transform: translateY(15px) scale(.98);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.nsc-widget.is-open .nsc-widget__panel { opacity: 1; transform: none; pointer-events: auto; }
.nsc-widget.is-open .nsc-widget__launcher { visibility: hidden; }

.nsc-widget__header {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 11px;
    align-items: center;
    padding: 14px 15px;
    color: #fff;
    background: linear-gradient(135deg, #b9141b, #dc1c23 72%, #ea3b40);
}

.nsc-widget.is-offline .nsc-widget__header { background: linear-gradient(135deg, #48535f, #687586); }
.nsc-widget.is-offline .nsc-widget__launcher-button { background: #596775; box-shadow: 0 12px 30px rgba(55, 68, 81, .24); }

.nsc-widget__avatar {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid rgba(255,255,255,.34);
    border-radius: 12px;
    background: rgba(255,255,255,.15);
    font-size: 18px;
    font-weight: 900;
}

.nsc-widget__title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.nsc-widget__status { display: block; margin-top: 2px; color: rgba(255,255,255,.86); font-size: 11px; }
.nsc-widget__close { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 9px; color: #fff; background: transparent; cursor: pointer; font-size: 25px; }
.nsc-widget__close:hover { background: rgba(255,255,255,.13); }

.nsc-widget__messages {
    overflow-y: auto;
    padding: 17px 14px;
    background: #f7f9fb;
    overscroll-behavior: contain;
}

.nsc-widget__message { display: flex; margin-bottom: 10px; }
.nsc-widget__message.is-customer { justify-content: flex-end; }
.nsc-widget__bubble { max-width: 83%; padding: 10px 12px 7px; border: 1px solid var(--nsc-line); border-radius: 6px 14px 14px; background: #fff; box-shadow: 0 3px 8px rgba(24,38,56,.04); white-space: pre-wrap; overflow-wrap: anywhere; }
.nsc-widget__message.is-customer .nsc-widget__bubble { border-color: #cce6ce; border-radius: 14px 6px 14px 14px; background: #eaf7eb; }
.nsc-widget__time { display: block; margin-top: 4px; color: #8e99a5; font-size: 9px; text-align: right; }
.nsc-widget__empty { padding: 35px 20px; color: var(--nsc-muted); text-align: center; }
.nsc-widget__error { margin: 0 0 9px; padding: 8px 10px; border-radius: 8px; color: #99171c; background: #fff0f0; font-size: 12px; }

.nsc-widget__quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 13px; }
.nsc-widget__quick button { min-height: 34px; padding: 6px 10px; border: 1px solid #d6dee6; border-radius: 999px; color: var(--nsc-text); background: #fff; cursor: pointer; font-size: 11px; font-weight: 700; }
.nsc-widget__quick button:hover { border-color: #df8d91; background: #fff6f6; }

.nsc-widget__composer { padding: 10px 11px 11px; border-top: 1px solid var(--nsc-line); background: #fff; }
.nsc-widget__composer-row { display: grid; grid-template-columns: 1fr 42px; gap: 7px; align-items: end; }
.nsc-widget__input { width: 100%; min-height: 42px; max-height: 100px; padding: 10px 11px; resize: none; border: 1px solid #d2dbe4; border-radius: 10px; outline: 0; font: inherit; line-height: 20px; }
.nsc-widget__input:focus { border-color: #1f5f9d; box-shadow: 0 0 0 3px rgba(31,95,157,.1); }
.nsc-widget__send { display: grid; width: 42px; height: 42px; place-items: center; padding: 0; border: 0; border-radius: 10px; color: #fff; background: var(--nsc-brand); cursor: pointer; font-size: 18px; }
.nsc-widget__send:disabled { opacity: .45; cursor: default; }
.nsc-widget__tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; }
.nsc-widget__callback-open { padding: 3px 2px; border: 0; color: #1f5f9d; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.nsc-widget__privacy { color: #939da7; font-size: 9px; text-align: right; }
.nsc-widget__callback { display: none; gap: 7px; margin-top: 9px; padding: 10px; border-radius: 10px; background: var(--nsc-soft); }
.nsc-widget__callback.is-visible { display: grid; }
.nsc-widget__callback input { min-height: 40px; padding: 0 10px; border: 1px solid #ccd6df; border-radius: 8px; outline: 0; }
.nsc-widget__callback button { min-height: 40px; border: 0; border-radius: 8px; color: #fff; background: var(--nsc-brand); cursor: pointer; font-weight: 700; }
.nsc-widget__callback small { color: var(--nsc-muted); font-size: 9px; }
.nsc-widget__launcher-button:focus-visible, .nsc-widget button:focus-visible, .nsc-widget input:focus-visible, .nsc-widget textarea:focus-visible { outline: 3px solid rgba(31,95,157,.3); outline-offset: 2px; }

@media (max-width: 600px) {
    .nsc-widget { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); }
    .nsc-widget__launcher-label { display: none; }
    .nsc-widget__panel { position: fixed; inset: 0; width: 100%; height: 100dvh; min-height: 0; border: 0; border-radius: 0; transform: translateY(20px); }
    .nsc-widget__header { padding-top: max(13px, env(safe-area-inset-top)); }
    .nsc-widget__composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .nsc-widget__panel, .nsc-widget__launcher { transition: none; }
}
