.oc-support-chat {
    position: fixed;
    right: 16px;
    bottom: 16px;
    /* Above TRG live-results modal (10050) / stage-tools bump (10060) */
    z-index: 10120;
    font-family: var(--font, "Segoe UI", "Helvetica Neue", Arial, sans-serif);
}

.oc-support-chat[hidden] {
    display: none !important;
}

.oc-support-chat__launcher {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--accent, #2d6a5a);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(28, 38, 36, 0.18);
}

.oc-support-chat__launcher-icon {
    display: block;
    width: 24px;
    height: 24px;
}

.oc-support-chat__launcher-label {
    display: none;
}

/* Compact vertical rail on clinical editors: flush right edge, near bottom */
.oc-support-chat--editor {
    right: 0;
    bottom: 24px;
    top: auto;
    transform: none;
}

.oc-support-chat--editor .oc-support-chat__launcher {
    width: 36px;
    height: auto;
    min-height: 0;
    padding: 14px 6px;
    gap: 8px;
    flex-direction: column;
    border-radius: 10px 0 0 10px;
    box-shadow: -2px 2px 12px rgba(28, 38, 36, 0.14);
}

.oc-support-chat--editor .oc-support-chat__launcher-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.oc-support-chat--editor .oc-support-chat__launcher-label {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 0.02em;
}

.oc-support-chat--editor .oc-support-chat__badge {
    top: 4px;
    left: -4px;
    right: auto;
}

.oc-support-chat--editor .oc-support-chat__panel {
    right: 0;
    bottom: 16px;
    top: auto;
    transform: none;
    border-radius: 16px 0 0 16px;
}

.oc-support-chat--editor .oc-support-chat__panel.is-moved {
    border-radius: 16px;
}

.oc-support-chat__launcher:hover,
.oc-support-chat__launcher:focus-visible {
    background: var(--accent-dark, #245648);
    outline: none;
}

.oc-support-chat__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 5px;
    border-radius: 999px;
    background: #fff;
    color: var(--accent-dark, #245648);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
    box-shadow: 0 1px 4px rgba(28, 38, 36, 0.2);
}

.oc-support-chat__panel {
    --oc-chat-frame: 5px;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 10121;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: min(380px, calc(100vw - 24px));
    height: min(520px, calc(100vh - 32px));
    min-width: 280px;
    min-height: 280px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    padding: 0;
    background: #fff;
    border: 1px solid var(--border, #cfd9d5);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(28, 38, 36, 0.16);
    overflow: hidden;
    touch-action: none;
}

.oc-support-chat:not(.oc-support-chat--cabinet) .oc-support-chat__panel {
    padding: var(--oc-chat-frame);
    border: 1px solid var(--border, #cfd9d5);
    background: #fff;
    box-shadow:
        0 0 0 1px rgba(28, 38, 36, 0.06),
        0 12px 40px rgba(28, 38, 36, 0.16);
}

.oc-support-chat__panel.is-moved {
    right: auto;
    bottom: auto;
    border-radius: 16px;
}

.oc-support-chat__panel[hidden] {
    display: none !important;
}

.oc-support-chat__resize {
    position: absolute;
    z-index: 3;
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
}

.oc-support-chat__resize--n {
    top: 0;
    left: var(--oc-chat-frame);
    right: var(--oc-chat-frame);
    height: var(--oc-chat-frame);
    cursor: ns-resize;
}

.oc-support-chat__resize--s {
    bottom: 0;
    left: var(--oc-chat-frame);
    right: var(--oc-chat-frame);
    height: var(--oc-chat-frame);
    cursor: ns-resize;
}

.oc-support-chat__resize--w {
    top: var(--oc-chat-frame);
    bottom: var(--oc-chat-frame);
    left: 0;
    width: var(--oc-chat-frame);
    cursor: ew-resize;
}

.oc-support-chat__resize--e {
    top: var(--oc-chat-frame);
    bottom: var(--oc-chat-frame);
    right: 0;
    width: var(--oc-chat-frame);
    cursor: ew-resize;
}

.oc-support-chat__resize--nw,
.oc-support-chat__resize--ne,
.oc-support-chat__resize--sw,
.oc-support-chat__resize--se {
    width: calc(var(--oc-chat-frame) + 6px);
    height: calc(var(--oc-chat-frame) + 6px);
    background: #fff;
}

.oc-support-chat__resize--nw {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.oc-support-chat__resize--ne {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.oc-support-chat__resize--sw {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

.oc-support-chat__resize--se {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

.oc-support-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px 14px;
    background: var(--bg-soft, #f2f5f4);
    border-bottom: 1px solid var(--border, #cfd9d5);
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.oc-support-chat__header:active {
    cursor: grabbing;
}

.oc-support-chat__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text, #1c2624);
}

.oc-support-chat__header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.oc-support-chat__gear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #5c6a66);
    cursor: pointer;
}

.oc-support-chat__gear:hover,
.oc-support-chat__gear:focus-visible,
.oc-support-chat__gear[aria-expanded="true"] {
    background: var(--bg-muted, #e6ecea);
    color: var(--text, #1c2624);
    outline: none;
}

.oc-support-chat__gear[hidden],
.oc-support-chat__title[hidden] {
    display: none !important;
}

.oc-support-chat__body {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.oc-support-chat__body[hidden] {
    display: none !important;
}

.oc-support-chat__settings-pane {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 16px 16px;
    overflow: auto;
}

.oc-support-chat__settings-pane[hidden] {
    display: none !important;
}

.oc-support-chat__settings-top {
    display: flex;
    justify-content: flex-end;
    margin: 0 -4px;
}

.oc-support-chat__settings-text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text, #1c2624);
}

.oc-support-chat__settings-action {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--accent, #2d6a5a);
    color: #fff;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.oc-support-chat__settings-action:hover,
.oc-support-chat__settings-action:focus-visible {
    background: var(--accent-dark, #245648);
    outline: none;
}

.oc-support-chat__settings-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.oc-support-chat__close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #5c6a66);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}

.oc-support-chat__close:hover,
.oc-support-chat__close:focus-visible {
    background: var(--bg-muted, #e6ecea);
    outline: none;
}

.oc-support-chat__meta {
    display: grid;
    gap: 8px;
    padding: 10px 16px 0;
}

.oc-support-chat__meta[hidden] {
    display: none !important;
}

.oc-support-chat__field {
    display: grid;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-muted, #5c6a66);
}

.oc-support-chat__field input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #cfd9d5);
    border-radius: 8px;
    font: inherit;
    color: var(--text, #1c2624);
}

.oc-support-chat__thread {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.oc-support-chat__messages {
    flex: 1 1 auto;
    overflow: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Page scroll lock while fullscreen mobile chat is open */
html.oc-support-chat-scroll-lock,
html.oc-support-chat-scroll-lock body {
    overflow: hidden;
    overscroll-behavior: none;
}

body.oc-support-chat-scroll-lock {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
}

.oc-support-chat__msg {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--bg-soft, #f2f5f4);
    color: var(--text, #1c2624);
    font-size: 0.92rem;
    line-height: 1.4;
}

.oc-support-chat__msg--visitor {
    align-self: flex-end;
    background: var(--accent-soft, #d5e6e1);
}

.oc-support-chat__msg--staff {
    align-self: flex-start;
}

.oc-support-chat__msg-author {
    display: block;
    margin-bottom: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #5c6a66);
}

.oc-support-chat__msg-body {
    white-space: pre-wrap;
    word-break: break-word;
}

.oc-support-chat__msg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.oc-support-chat__msg-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(45, 106, 90, 0.35);
    background: #fff;
    color: var(--accent, #2d6a5a);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.oc-support-chat__msg-action:hover,
.oc-support-chat__msg-action:focus-visible {
    background: rgba(45, 106, 90, 0.08);
    outline: none;
}

.oc-support-chat__draft {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 12px;
    padding: 8px 16px 10px;
    border-top: 1px solid var(--border, #cfd9d5);
    background: #f7f9f8;
}

.oc-support-chat__draft[hidden] {
    display: none !important;
}

.oc-support-chat__draft-status {
    flex: 1 1 10rem;
    margin: 0;
    min-width: 0;
    font-size: 0.85rem;
    line-height: 1.35;
    color: var(--text-muted, #5c6a66);
}

.oc-support-chat__draft-bubble {
    flex: 0 0 auto;
    width: 72px;
}

.oc-support-chat__draft-media {
    position: relative;
    overflow: hidden;
    width: 72px;
    height: 72px;
    border-radius: 10px;
    background: var(--accent-soft, #d5e6e1);
    box-shadow: 0 1px 2px rgba(28, 38, 36, 0.08);
}

.oc-support-chat__draft-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.oc-support-chat__draft-clear {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(8, 12, 18, 0.55);
    color: #fff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}

.oc-support-chat__draft-clear:hover,
.oc-support-chat__draft-clear:focus-visible {
    background: rgba(8, 12, 18, 0.75);
    outline: none;
}

.oc-support-chat__draft-sending {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(8, 12, 18, 0.45);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
}

.oc-support-chat__draft-sending[hidden] {
    display: none !important;
}

.oc-support-chat__draft-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 999px;
    animation: oc-support-chat-spin 0.7s linear infinite;
}

.oc-support-chat__draft-sending span:not(.oc-support-chat__draft-spinner) {
    display: none;
}

@keyframes oc-support-chat-spin {
    to { transform: rotate(360deg); }
}

.oc-support-chat__draft.is-sending .oc-support-chat__draft-clear {
    display: none;
}

.oc-support-chat__drop {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(28, 38, 36, 0.55);
    pointer-events: none;
}

.oc-support-chat__drop[hidden] {
    display: none !important;
}

.oc-support-chat__drop-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: min(100%, 260px);
    padding: 28px 20px;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

.oc-support-chat__composer {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: stretch;
    gap: 8px;
    padding: 12px 16px 8px;
    border-top: 1px solid var(--border, #cfd9d5);
    background: #fff;
}

.oc-support-chat__composer [data-oc-chat-image-input] {
    display: none;
}

.oc-support-chat__attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--border, #cfd9d5);
    border-radius: 10px;
    background: #fff;
    color: var(--text-muted, #5a6b66);
    cursor: pointer;
    flex: 0 0 auto;
}

.oc-support-chat__attach:hover,
.oc-support-chat__attach:focus-visible {
    color: var(--accent, #2d6a5a);
    border-color: var(--accent, #2d6a5a);
    outline: none;
}

.oc-support-chat__attach:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.oc-support-chat__msg--media {
    padding: 4px;
    overflow: hidden;
}

.oc-support-chat__msg--media .oc-support-chat__msg-author {
    padding: 4px 8px 0;
    margin-bottom: 4px;
}

.oc-support-chat__msg--media .oc-support-chat__msg-body {
    padding: 4px 8px 8px;
}

.oc-support-chat__msg--media .oc-support-chat__msg-image {
    margin: 0;
    max-width: none;
}

.oc-support-chat__msg--visitor.oc-support-chat__msg--media {
    border-radius: 14px 14px 4px 14px;
}

.oc-support-chat__msg--staff.oc-support-chat__msg--media {
    border-radius: 14px 14px 14px 4px;
}

.oc-support-chat__msg-image {
    display: block;
    margin: 6px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    max-width: min(100%, 260px);
    width: 100%;
}

.oc-support-chat__msg-image img {
    display: block;
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: 10px;
}

.oc-support-chat__msg--media .oc-support-chat__msg-image img {
    border-radius: 10px;
}

.oc-support-chat__msg-image-removed {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted, #5a6b66);
    font-style: italic;
}

.oc-support-chat__input {
    width: 100%;
    resize: vertical;
    min-height: 44px;
    max-height: var(--oc-chat-input-max, 40vh);
    padding: 10px 12px;
    border: 1px solid var(--border, #cfd9d5);
    border-radius: 10px;
    font: inherit;
    line-height: 1.4;
    color: var(--text, #1c2624);
    box-sizing: border-box;
}

.oc-support-chat__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-height: 44px;
    height: auto;
    align-self: stretch;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--accent, #2d6a5a);
    color: #fff;
    cursor: pointer;
    flex: 0 0 auto;
}

.oc-support-chat__send:hover,
.oc-support-chat__send:focus-visible {
    background: var(--accent-dark, #245648);
    outline: none;
}

.oc-support-chat__send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.oc-support-chat__error {
    margin: 0;
    padding: 0 16px 12px;
    color: var(--danger, #c45c5c);
    font-size: 0.85rem;
}

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

/* Embedded in Account → Overview */
.oc-support-chat--cabinet {
    position: relative;
    right: auto;
    bottom: auto;
    z-index: auto;
    width: 100%;
}

.oc-support-chat--cabinet .oc-support-chat__panel {
    position: relative;
    right: auto;
    left: auto;
    bottom: auto;
    width: 100%;
    height: min(480px, 70vh);
    max-height: none;
    border-radius: 12px;
    box-shadow: none;
    touch-action: auto;
}

.oc-support-chat--cabinet .oc-support-chat__header {
    cursor: default;
    touch-action: auto;
}

.oc-support-chat--cabinet .oc-support-chat__header:active {
    cursor: default;
}

.cabinet-support-chat-wrap {
    width: 100%;
}

#cabinet-support-chat {
    margin-bottom: 16px;
}

/* TRG editor mobile: launcher bottom-center, flush to screen edge.
   Do NOT use transform on the root — it becomes the containing block for the
   position:fixed panel and collapses the chat window to the launcher box. */
@media (max-width: 900px) {
    body:has(.trg-page) .oc-support-chat--editor {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: max-content;
        max-width: calc(100vw - 16px);
        margin-inline: auto;
        transform: none;
    }

    body:has(.trg-page) .oc-support-chat--editor .oc-support-chat__launcher {
        width: auto;
        height: 44px;
        min-height: 44px;
        padding: 8px 14px;
        flex-direction: row;
        gap: 8px;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -2px 16px rgba(28, 38, 36, 0.16);
    }

    body:has(.trg-page) .oc-support-chat--editor .oc-support-chat__launcher-label {
        writing-mode: horizontal-tb;
        transform: none;
        font-size: 0.8125rem;
        letter-spacing: 0;
    }

    body:has(.trg-page) .oc-support-chat--editor .oc-support-chat__badge {
        top: -4px;
        right: -4px;
        left: auto;
    }
}

@media (max-width: 576px) {
    .oc-support-chat {
        right: 12px;
        bottom: 12px;
    }

    .oc-support-chat--editor {
        right: 0;
        bottom: 16px;
        top: auto;
        transform: none;
    }

    /* Keep TRG override above the generic editor rail reset */
    body:has(.trg-page) .oc-support-chat--editor {
        left: 0;
        right: 0;
        bottom: 0;
        width: max-content;
        max-width: calc(100vw - 16px);
        margin-inline: auto;
        transform: none;
    }

    .oc-support-chat:not(.oc-support-chat--cabinet) .oc-support-chat__panel,
    .oc-support-chat--editor .oc-support-chat__panel {
        position: fixed;
        top: var(--site-header-height, 72px);
        right: 0;
        left: 0;
        bottom: 0;
        width: auto;
        min-width: 0;
        max-width: none;
        height: auto;
        min-height: 0;
        max-height: none;
        border-radius: 0;
        border: none;
        padding: 0;
        box-shadow: none;
        touch-action: auto;
        overscroll-behavior: contain;
    }

    .oc-support-chat:not(.oc-support-chat--cabinet) .oc-support-chat__panel.is-moved,
    .oc-support-chat--editor .oc-support-chat__panel.is-moved {
        right: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        top: var(--site-header-height, 72px) !important;
        width: auto !important;
        max-width: none !important;
        border-radius: 0;
    }

    .oc-support-chat:not(.oc-support-chat--cabinet) .oc-support-chat__resize {
        display: none !important;
    }

    .oc-support-chat:not(.oc-support-chat--cabinet) .oc-support-chat__header {
        cursor: default;
        touch-action: auto;
    }

    .oc-support-chat:not(.oc-support-chat--cabinet) .oc-support-chat__header:active {
        cursor: default;
    }

    .oc-support-chat--cabinet .oc-support-chat__panel {
        height: min(420px, 65vh);
    }
}

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