:root {
    --v3-chat-bottom-inset: env(safe-area-inset-bottom, 0px);
}

html:has(.v3-chat-dock.is-fullscreen, .v3-chat-rules[open]) { overflow: hidden; }

.v3-chat-dock {
    position: fixed;
    z-index: 95;
    inset: auto 22px 18px auto;
    width: min(356px, calc(100vw - 28px));
    color: #eeeaf3;
    font: 400 14px/1.4 system-ui, sans-serif;
}

.v3-chat-dock > .v3-chat-drawer[hidden] { display: none; }
.v3-chat-dock.is-open {
    width: min(712px, calc(100vw - 28px));
    height: min(520px, calc(100dvh - 40px));
    min-width: min(300px, calc(100vw - 28px));
    min-height: min(320px, calc(100dvh - 40px));
    max-width: calc(100vw - 28px);
    max-height: calc(100dvh - 40px);
    overflow: hidden;
    resize: none;
}
.v3-chat-dock.is-guest.is-open { height: auto; min-height: 0; resize: none; }
.v3-chat-dock.is-open > .v3-chat-drawer { width: 100%; height: 100%; }
.v3-chat-dock.is-guest.is-open > .v3-chat-drawer { height: auto; }
.v3-chat-dock.is-minimized {
    width: 56px;
    height: 56px;
    overflow: hidden;
    resize: none;
}

.v3-chat-dock .v3-chat-strip {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 58px;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border: 1px solid #51466e;
    border-radius: 16px;
    background: linear-gradient(135deg, #292337, #191720 72%);
    color: #e5e3eb;
    box-shadow: 0 12px 34px #0008, inset 0 1px #ffffff0c;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.3;
    text-align: start;
    cursor: pointer;
}

.v3-chat-strip:hover { border-color: #9179c7; background: linear-gradient(135deg, #342b48, #201c29 72%); }
.v3-chat-dock .v3-chat-strip:focus-visible { outline: 2px solid #ad96f4; outline-offset: -2px; }
.v3-chat-dock.is-open > .v3-chat-strip { display: none; }
.v3-chat-strip-marker {
    position: relative;
    width: 36px;
    height: 36px;
    flex: none;
    border: 1px solid #746292;
    border-radius: 12px;
    background: #362c49;
}
.v3-chat-strip-marker::before {
    position: absolute;
    inset: 9px;
    border: 2px solid #d8c6ff;
    border-radius: 50%;
    content: '';
}
.v3-chat-strip-marker::after {
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 8px;
    height: 8px;
    border: 2px solid #292337;
    border-radius: 50%;
    background: #9fdf73;
    content: '';
}
.v3-chat-strip-label { flex: none; color: #f2e9fc; font-weight: 750; }

.v3-chat-strip-author,
.v3-chat-strip-message {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3-chat-strip-author {
    max-width: min(32%, 16rem);
    color: #bce676;
    font-weight: 700;
}

.v3-chat-strip-message { flex: 1; }
.v3-chat-strip-author[hidden], .v3-chat-strip-message[hidden] { display: none; }

.v3-chat-strip-arrow {
    width: 7px;
    height: 7px;
    flex: none;
    margin: 0 2px 0 auto;
    border-top: 1px solid currentColor;
    border-right: 1px solid currentColor;
    color: #c3b5d7;
    transform: rotate(-45deg);
}

.v3-chat-strip:hover .v3-chat-strip-arrow { color: #f4edf9; }
.v3-chat-dock.is-minimized .v3-chat-strip {
    width: 56px;
    height: 56px;
    min-height: 56px;
    justify-content: center;
    padding: 9px;
    border-radius: 50%;
}
.v3-chat-dock.is-minimized .v3-chat-strip-marker { border-radius: 50%; }
.v3-chat-dock.is-minimized .v3-chat-strip-label,
.v3-chat-dock.is-minimized .v3-chat-strip-author,
.v3-chat-dock.is-minimized .v3-chat-strip-message,
.v3-chat-dock.is-minimized .v3-chat-strip-arrow { display: none; }
.v3-chat-compact-shrink {
    display: flex;
    position: absolute;
    z-index: 2;
    top: -8px;
    right: -8px;
    min-width: 28px;
    height: 28px;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
    border: 1px solid #746292;
    border-radius: 14px;
    background: #211b2c;
    color: #eeeaf3;
    font: 650 11px/1 system-ui, sans-serif;
    opacity: 0;
    pointer-events: none;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity .15s ease;
}
.v3-chat-compact-shrink span {
    width: 10px;
    height: 1px;
    background: currentColor;
}
.v3-chat-dock.is-compact:hover .v3-chat-compact-shrink,
.v3-chat-dock.is-compact:focus-within .v3-chat-compact-shrink {
    opacity: 1;
    pointer-events: auto;
}
.v3-chat-dock.is-open .v3-chat-compact-shrink,
.v3-chat-dock.is-minimized .v3-chat-compact-shrink { display: none; }

.v3-chat-drawer .v3-chat-room {
    --chat-border: #292832;
    --chat-muted: #a6a4b5;
    --chat-accent: #c5b2ff;
    --chat-avatar-size: 36px;
    display: grid;
    position: relative;
    width: 100%;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    background: #131318;
    box-shadow: 0 16px 48px #0009;
}
.v3-chat-drawer .v3-chat-room-heading { padding-left: 34px; }
.v3-chat-resize-handles { position: absolute; z-index: 4; inset: 0; pointer-events: none; }
.v3-chat-resize-handles button {
    position: absolute;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: #b8a5df;
    pointer-events: auto;
}
.v3-chat-resize-handles button:hover { background: #ad8bef22; }
.v3-chat-resize-handles button:focus-visible { outline: 2px solid #c5b2ff; outline-offset: -2px; }
.v3-chat-resize-handles [data-chat-resize="left"] {
    inset: 38px auto 38px 0;
    width: 12px;
    cursor: ew-resize;
    touch-action: none;
}
.v3-chat-resize-handles [data-chat-resize="left"] span {
    width: 3px;
    height: 38px;
    border-radius: 3px;
    background: currentColor;
}
.v3-chat-resize-handles [data-chat-resize="top"] {
    inset: 0 38px auto 38px;
    height: 12px;
    cursor: ns-resize;
    touch-action: none;
}
.v3-chat-resize-handles [data-chat-resize="top"] span {
    width: 38px;
    height: 3px;
    border-radius: 3px;
    background: currentColor;
}
.v3-chat-resize-handles [data-chat-resize="top-left"] {
    inset: 0 auto auto 0;
    width: 30px;
    height: 34px;
    cursor: nwse-resize;
    touch-action: none;
}
.v3-chat-resize-handles [data-chat-resize="top-left"] span {
    width: 12px;
    height: 12px;
    border-top: 2px solid currentColor;
    border-left: 2px solid currentColor;
    border-radius: 3px 0 0;
}
.v3-chat-dock.is-fullscreen .v3-chat-resize-handles { display: none; }
.v3-chat-drawer .v3-chat-room:not([data-chat-room]) { height: auto; grid-template-rows: auto auto; }

.v3-chat-dock.is-fullscreen {
    z-index: 10001;
    inset: 0;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    max-width: none;
    max-height: none;
    overflow: visible;
    resize: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: var(--v3-chat-bottom-inset);
    padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
}
.v3-chat-dock.is-fullscreen .v3-chat-drawer,
.v3-chat-dock.is-fullscreen .v3-chat-room { height: 100%; }
.v3-chat-dock.is-fullscreen .v3-chat-room { border-top: 0; }
.v3-chat-dock.is-fullscreen .v3-chat-room:not([data-chat-room]) { align-content: space-between; }

.v3-chat-drawer .v3-chat-room-heading {
    gap: 10px;
    min-height: 34px;
    padding: 0 8px 0 34px;
    background: #15151b;
}

.v3-chat-drawer .v3-chat-room-title h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #efedf7;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.v3-chat-drawer .v3-chat-room-title h2::before {
    width: 13px;
    height: 2px;
    flex: none;
    background: #ab91f4;
    content: '';
}

.v3-chat-drawer .v3-chat-connection { font-size: 11px; }
.v3-chat-header-actions { display: flex; flex: none; margin-inline-start: auto; align-self: stretch; }
.v3-chat-connection:not([hidden]) + .v3-chat-header-actions { margin-inline-start: 0; }
.v3-chat-header-actions button {
    display: grid;
    width: 42px;
    min-height: 34px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #aaa2bb;
    cursor: pointer;
}
.v3-chat-header-actions button:hover { background: #262230; color: #e5d9ff; }
.v3-chat-header-actions button:focus-visible { outline: 2px solid #c5b2ff; outline-offset: -2px; }
.v3-chat-header-actions svg { width: 17px; height: 17px; }
.v3-chat-contract-icon, .v3-chat-dock.is-fullscreen .v3-chat-expand-icon { display: none; }
.v3-chat-dock.is-fullscreen .v3-chat-contract-icon { display: block; }

.v3-chat-drawer .v3-chat-history { min-height: 0; }
.v3-chat-drawer .v3-chat-scroller {
    position: relative;
    height: 100%;
    scrollbar-color: #514a65 #15151b;
}

.v3-chat-drawer .v3-chat-messages { padding: 6px 12px; }
.v3-chat-drawer .v3-chat-message {
    grid-template-columns: var(--chat-avatar-size) minmax(0, 1fr) auto;
    gap: 10px;
    padding: 7px 0;
}
.v3-chat-drawer .v3-chat-message + .v3-chat-message { border-top: 0; }
.v3-chat-drawer .v3-chat-message:has(+ .is-continuation) { padding-bottom: 2px; }
.v3-chat-drawer .v3-chat-message.is-continuation { padding-top: 2px; }
.v3-chat-message.is-continuation > .v3-chat-avatar-frame,
.v3-chat-message.is-continuation .v3-chat-message-meta { display: none; }
.v3-chat-message.is-continuation .v3-chat-message-copy { grid-column: 2; }
.v3-chat-drawer .v3-chat-message.is-continuation .v3-chat-message-actions button {
    min-height: 22px;
    padding-block: 0;
}
.v3-chat-drawer .v3-chat-avatar {
    width: var(--chat-avatar-size);
    height: var(--chat-avatar-size);
    border-color: #464151;
    background: #24222f;
}

.v3-chat-drawer .v3-chat-message-meta .v3-chat-author { color: #c5ea89; }
.v3-chat-drawer .v3-chat-message-text {
    margin-top: 2px;
    color: #e3e0e9;
    font-size: 13px;
    line-height: 1.45;
}

.v3-chat-drawer .v3-chat-empty { font-size: 13px; }
.v3-chat-drawer .v3-chat-actions { padding: 8px 10px; background: #15151b; }
.v3-chat-drawer .v3-chat-room:has(.v3-chat-gif-panel:not([hidden]), .v3-chat-gif-preview:not([hidden])) {
    grid-template-rows: auto minmax(0, 1fr) minmax(0, max-content);
}
.v3-chat-drawer .v3-chat-actions:has(.v3-chat-gif-panel:not([hidden]), .v3-chat-gif-preview:not([hidden])) {
    min-height: 0;
    overflow-y: auto;
}
.v3-chat-drawer .v3-chat-composer {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
}
.v3-chat-drawer .v3-chat-composer > :is(textarea, .v3-chat-gif-preview, .v3-chat-composer-tools, .v3-chat-emoji-panel, .v3-chat-gif-panel, .v3-chat-composer-footer) {
    grid-column: 1 / -1;
}

.v3-chat-drawer .v3-chat-composer textarea {
    min-height: 40px;
    max-height: min(92px, 22dvh);
    padding: 8px 10px;
    border-color: #373443;
    background: #101016;
    color: #f0edf8;
    font-size: 13px;
    line-height: 1.35;
}

.v3-chat-drawer .v3-chat-composer-footer { gap: 8px; }
.v3-chat-composer-tools { display: flex; align-items: center; gap: 6px; }
.v3-chat-composer-tools button,
.v3-chat-gif-search button {
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid #393443;
    border-radius: 7px;
    background: #1b1822;
    color: #d8c8f1;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.v3-chat-composer-tools button:hover:not(:disabled),
.v3-chat-gif-search button:hover:not(:disabled) { border-color: #756096; background: #282133; }
.v3-chat-composer-tools button:disabled,
.v3-chat-gif-search button:disabled { cursor: default; opacity: .5; }
.v3-chat-emoji-panel,
.v3-chat-gif-panel {
    min-width: 0;
    padding: 9px;
    border: 1px solid #35303f;
    border-radius: 9px;
    background: #191720;
}
.v3-chat-emoji-panel[hidden],
.v3-chat-gif-panel[hidden],
.v3-chat-gif-preview[hidden] { display: none !important; }
.v3-chat-emoji-panel { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.v3-chat-emoji {
    min-width: 0;
    min-height: 32px;
    padding: 2px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font-size: 19px;
    cursor: pointer;
}
.v3-chat-emoji:hover { background: #312a3d; }
.v3-chat-gif-search { display: flex; gap: 6px; }
.v3-chat-gif-search input {
    min-width: 0;
    min-height: 34px;
    flex: 1;
    padding: 5px 9px;
    border: 1px solid #393443;
    border-radius: 7px;
    background: #101016;
    color: #f0edf8;
    font: inherit;
    font-size: 13px;
}
.v3-chat-gif-search input:focus-visible { border-color: #a98be3; outline: 2px solid #a98be344; }
.v3-chat-gif-panel > p { min-height: 16px; margin: 6px 0; color: #aaa4b6; font-size: 11px; }
.v3-chat-gif-panel {
    box-sizing: border-box;
    width: 100%;
    max-width: 960px;
}
.v3-chat-gif-results {
    display: grid;
    max-height: clamp(112px, 27dvh, 232px);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 100px), 1fr));
    gap: 6px;
    overflow: auto;
}
.v3-chat-dock.is-fullscreen .v3-chat-gif-results {
    max-height: clamp(112px, 34dvh, 300px);
}
.v3-chat-gif-result {
    min-width: 0;
    height: clamp(88px, 16dvh, 112px);
    padding: 0;
    overflow: hidden;
    border: 1px solid #393443;
    border-radius: 6px;
    background: #100f14;
    cursor: pointer;
}
.v3-chat-gif-result:hover { border-color: #b69be9; }
.v3-chat-gif-result img { display: block; width: 100%; height: 100%; object-fit: contain; }
.v3-chat-gif-preview { display: flex; min-width: 0; align-items: center; gap: 8px; color: #bdb5cc; font-size: 12px; }
.v3-chat-gif-preview img {
    width: auto;
    max-width: min(196px, 55%);
    height: clamp(72px, 22dvh, 120px);
    border-radius: 5px;
    object-fit: contain;
}
.v3-chat-gif-preview button { width: 28px; min-height: 28px; margin-inline-start: auto; border: 1px solid #494052; border-radius: 50%; background: #211c29; color: inherit; font: inherit; font-size: 17px; cursor: pointer; }
.v3-chat-drawer .v3-chat-gif { display: block; width: auto; max-width: min(240px, 100%); max-height: 180px; margin-top: 5px; border-radius: 8px; object-fit: contain; }
.v3-chat-drawer .v3-chat-character-count { font-size: 11px; white-space: nowrap; }
.v3-chat-drawer .v3-chat-room .v3-chat-send {
    min-height: 40px;
    padding-inline: 11px;
    border-color: #ae98ed;
    background: #af98ef;
    color: #211933;
    font-size: 13px;
}

.v3-chat-drawer .v3-chat-room .v3-chat-send:hover:not(:disabled) { background: #c6b2ff; }
.v3-chat-drawer .v3-chat-room .v3-chat-latest {
    border-color: #5d5079;
    background: #2c253d;
    color: #e0d3ff;
}

.v3-chat-drawer .v3-chat-actions .v3-chat-drawer-sign-in {
    display: flex;
    min-height: 40px;
    align-items: center;
    padding-inline: 12px;
    border: 1px solid var(--chat-border);
    border-radius: 7px;
    background: #101016;
    color: #c5b2ff;
    font-size: 13px;
    font-weight: 650;
}

.v3-chat-drawer .v3-chat-actions .v3-chat-drawer-sign-in:hover { border-color: #665687; color: #e0d3ff; }

.v3-chat-rules {
    width: min(516px, calc(100% - 24px));
    max-height: min(88dvh, 680px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #3a3347;
    border-radius: 13px;
    background: #191720;
    color: #dcd7e8;
    font: 400 14px/1.5 system-ui, sans-serif;
}
.v3-chat-rules::backdrop { background: #08070bc9; }
.v3-chat-rules-panel { display: flex; flex-direction: column; max-height: inherit; margin: 0; }
.v3-chat-rules-heading, .v3-chat-rules-footer {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 15px;
}
.v3-chat-rules-heading { border-bottom: 1px solid #322c3d; }
.v3-chat-rules-heading h2 { margin: 0; color: #f1ebfb; font-size: 15px; }
.v3-chat-rules-heading button {
    width: 36px;
    min-height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #bcb2ce;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}
.v3-chat-rules-heading button:hover { background: #2d263b; color: #fff; }
.v3-chat-rules-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 13px 15px 15px; }
.v3-chat-rules-content p { margin: 0; }
.v3-chat-rules-content ol { display: grid; gap: 7px; margin: 0 0 14px; padding-inline-start: 22px; }
.v3-chat-rules-content strong { color: #f1ebfb; }
.v3-chat-rules-note { color: #bfb5cd; font-size: 12px; }
.v3-chat-rules-footer { justify-content: flex-end; border-top: 1px solid #322c3d; }
.v3-chat-rules-consent {
    display: grid;
    gap: 9px;
    padding: 12px 15px;
    border-top: 1px solid #322c3d;
    background: #201b29;
}
.v3-chat-rules-consent[hidden] { display: none !important; }
.v3-chat-rules-consent label { display: flex; align-items: flex-start; gap: 9px; color: #eee8f7; }
.v3-chat-rules-consent input { width: 18px; height: 18px; flex: none; margin: 1px 0 0; accent-color: #ad8bef; }
.v3-chat-rules-consent button {
    min-height: 42px;
    padding: 7px 14px;
    border: 1px solid #a887ed;
    border-radius: 8px;
    background: #ad8bef;
    color: #231535;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.v3-chat-rules-consent button:disabled { cursor: default; opacity: .55; }
.v3-chat-rules-consent button:focus-visible { outline: 2px solid #decfff; outline-offset: 2px; }
.v3-chat-rules-status { margin: 0; color: #ffb7be; font-size: 13px; }
.v3-chat-rules-footer button {
    min-height: 40px;
    min-width: 82px;
    padding: 6px 15px;
    border: 1px solid #a887ed;
    border-radius: 8px;
    background: #ad8bef;
    color: #231535;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.v3-chat-rules-footer button:hover { background: #c7a9fa; }
.v3-chat-rules button:focus-visible { outline: 2px solid #decfff; outline-offset: 2px; }

.v3-chat-message-menu .v3-chat-menu-timeout {
    margin-top: 4px;
    border-top-color: var(--chat-border);
}
.v3-chat-timeout-fields { display: grid; gap: 8px; }
.v3-chat-timeout-fields label { font-size: 13px; font-weight: 650; }
.v3-chat-timeout-fields :is(select, textarea) {
    box-sizing: border-box;
    width: 100%;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid #474051;
    border-radius: 7px;
    background: #101016;
    color: inherit;
    color-scheme: dark;
    font: inherit;
}
.v3-chat-timeout-fields textarea { resize: vertical; }
.v3-chat-timeout-form .v3-chat-rules-footer { flex-wrap: wrap; gap: 8px; }
.v3-chat-timeout-form .v3-chat-timeout-remove { border-color: #5d5079; background: #2c253d; color: #e5d9ff; }
.v3-chat-timeout-form .v3-chat-timeout-remove:hover:not(:disabled) { background: #383049; }
.v3-chat-timeout-form button:disabled { cursor: default; opacity: .55; }

@media (max-width: 760px) {
    .v3-chat-dock {
        inset: auto 12px calc(82px + var(--v3-chat-bottom-inset)) auto;
        width: min(356px, calc(100vw - 24px));
    }
    .v3-chat-dock.is-open:not(.is-fullscreen) {
        width: min(356px, calc(100vw - 24px));
        height: min(68dvh, 580px, calc(100dvh - 116px - var(--v3-chat-bottom-inset)));
        min-width: min(300px, calc(100vw - 24px));
        min-height: min(320px, calc(100dvh - 116px - var(--v3-chat-bottom-inset)));
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 116px - var(--v3-chat-bottom-inset));
    }
    .v3-chat-dock.is-guest.is-open { height: auto; min-height: 0; }
    .v3-chat-dock .v3-chat-strip { min-height: 54px; }
    .v3-chat-drawer .v3-chat-room {
        --chat-avatar-size: 32px;
        border-radius: 16px;
    }
    .v3-chat-header-actions button { width: 44px; min-height: 44px; }
    .v3-chat-drawer .v3-chat-composer textarea { font-size: 16px; }
    .v3-chat-emoji-panel { grid-template-columns: repeat(7, minmax(0, 1fr)); }
    .v3-chat-drawer .v3-chat-room .v3-chat-send { min-height: 44px; }
    .v3-chat-drawer .v3-chat-composer-footer { flex-wrap: wrap; justify-content: flex-end; gap: 3px 8px; }
}

@media (pointer: coarse) {
    .v3-chat-dock .v3-chat-strip { min-height: 54px; }
    .v3-chat-dock .v3-chat-compact-shrink { display: none; }
    .v3-chat-drawer .v3-chat-message.is-continuation .v3-chat-message-actions button { min-height: 32px; }
}

@media (max-width: 760px) {
    .v3-chat-dock .v3-chat-compact-shrink { display: none; }
}
