.dream-chat {
    position: fixed;
    left: 26px;
    bottom: 26px;
    z-index: 88;
    font-family: inherit;
}

.dream-chat-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    min-width: 126px;
    height: 48px;
    padding: 0 18px;
    border: 1px solid color-mix(in oklch, var(--primary) 24%, var(--line));
    border-radius: 999px;
    color: var(--primary);
    background:
        radial-gradient(circle at 32% 24%, rgba(255, 255, 255, .96), rgba(255, 255, 255, .72)),
        color-mix(in oklch, var(--card-solid) 84%, transparent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .72),
        0 14px 34px rgba(19, 27, 45, .16);
    backdrop-filter: blur(14px);
    cursor: pointer;
    transition: transform .18s ease, color .18s ease, background .18s ease, box-shadow .18s ease;
}

.dream-chat-fab svg {
    width: 19px;
    height: 19px;
    stroke-width: 2.2;
}

.dream-chat-fab span {
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
}

.dream-chat.open .dream-chat-fab {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, #10a87b, color-mix(in oklch, var(--primary) 72%, #10a87b));
    box-shadow: 0 16px 34px rgba(16, 168, 123, .28);
}

.dream-chat-fab:hover {
    transform: translateY(-2px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .78),
        0 18px 38px rgba(19, 27, 45, .2);
}

.dream-chat-panel {
    position: absolute;
    left: 0;
    bottom: 70px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
    width: min(420px, calc(100vw - 34px));
    height: min(662px, calc(100vh - 104px));
    overflow: hidden;
    border: 1px solid color-mix(in oklch, var(--line) 80%, transparent);
    border-radius: 22px;
    background: color-mix(in oklch, var(--card-solid) 94%, transparent);
    box-shadow: 0 24px 58px rgba(19, 27, 45, .16);
    backdrop-filter: blur(18px);
}

.dream-chat-panel[hidden] {
    display: none;
}

.dream-chat-header {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
    min-height: 50px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}

.dream-chat-header strong {
    min-width: 0;
    text-align: center;
    font-size: 20px;
    line-height: 1.2;
}

.dream-chat-header button,
.dream-chat-tools button,
.dream-chat-tools label {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid color-mix(in oklch, var(--line) 82%, transparent);
    border-radius: 8px;
    color: var(--text);
    background: color-mix(in oklch, var(--card-solid) 86%, transparent);
    cursor: pointer;
}

.dream-chat-header button {
    justify-self: center;
    border: 0;
    background: transparent;
}

.dream-chat-header svg,
.dream-chat-tools svg {
    width: 18px;
    height: 18px;
}

.dream-chat-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    padding: 14px 12px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in oklch, var(--text-soft) 34%, transparent) transparent;
}

.dream-chat-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
}

.dream-chat-item.own {
    grid-template-columns: minmax(0, 1fr) 34px;
}

.dream-chat-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #d7a255, #81b2a4);
    font-size: 13px;
    font-weight: 800;
}

.dream-chat-body {
    display: grid;
    justify-items: start;
    gap: 5px;
    min-width: 0;
}

.dream-chat-item.own .dream-chat-body {
    justify-items: end;
    grid-column: 1;
    grid-row: 1;
}

.dream-chat-item.own .dream-chat-avatar {
    grid-column: 2;
}

.dream-chat-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.2;
}

.dream-chat-name {
    color: var(--text-soft);
    font-weight: 800;
}

.dream-chat-badge {
    padding: 2px 7px;
    border-radius: 999px;
    background: #fff1bb;
    color: #9a6b00;
    font-size: 11px;
    font-weight: 800;
}

.dream-chat-badge.admin {
    background: #ffe0e7;
    color: #cf2d53;
}

.dream-chat-bubble {
    width: fit-content;
    max-width: min(270px, 72vw);
    padding: 10px 13px;
    border: 1px solid color-mix(in oklch, var(--line) 78%, transparent);
    border-radius: 13px;
    color: var(--text);
    background: color-mix(in oklch, var(--card-solid) 92%, transparent);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.dream-chat-item.own .dream-chat-bubble {
    color: #fff;
    border-color: transparent;
    background: var(--primary);
}

.dream-chat-image-wrap {
    position: relative;
    display: inline-block;
    width: fit-content;
    max-width: min(180px, 60vw);
}

.dream-chat-image {
    max-width: min(180px, 60vw);
    max-height: 210px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 8px 18px rgba(19, 27, 45, .12);
    cursor: default;
    user-select: none;
    -webkit-user-drag: none;
}

.dream-chat-fav-image {
    position: absolute;
    top: 7px;
    right: 7px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 50%;
    color: #fff;
    background: rgba(15, 23, 42, .46);
    box-shadow: 0 6px 14px rgba(15, 23, 42, .18);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.dream-chat-fav-image:hover {
    background: #10a87b;
}

.dream-chat-fav-image span {
    transform: translateY(-1px);
    font-size: 16px;
    line-height: 1;
}

.dream-chat-emoji-panel {
    margin: 0 12px 8px;
    overflow: hidden;
    border: 1px solid color-mix(in oklch, var(--line) 82%, transparent);
    border-radius: 10px;
    background: color-mix(in oklch, var(--card-solid) 96%, transparent);
    box-shadow: 0 10px 24px rgba(19, 27, 45, .08);
}

.dream-chat-emoji-panel[hidden] {
    display: none;
}

.dream-chat-emoji-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--line);
}

.dream-chat-emoji-tabs button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    font-weight: 700;
}

.dream-chat-emoji-tabs button.active {
    color: #0caa90;
    border-bottom-color: #0caa90;
}

.dream-chat-emoji-tabs svg {
    width: 16px;
    height: 16px;
}

.dream-chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px 10px;
    max-height: 210px;
    padding: 14px 18px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in oklch, var(--text-soft) 34%, transparent) transparent;
}

.dream-chat-emoji-grid.favorites {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dream-chat-emoji-grid button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 25px;
    line-height: 1;
}

.dream-chat-emoji-grid .dream-chat-favorite-item {
    width: 62px;
    height: 62px;
    border: 1px solid color-mix(in oklch, var(--line) 82%, transparent);
    background: color-mix(in oklch, var(--card-solid) 86%, transparent);
}

.dream-chat-favorite-item img {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 8px;
    pointer-events: none;
}

.dream-chat-favorite-empty {
    grid-column: 1 / -1;
    padding: 22px 8px;
    color: var(--text-soft);
    text-align: center;
    font-size: 13px;
}

.dream-chat-emoji-grid button:hover,
.dream-chat-emoji-grid button:focus-visible {
    background: color-mix(in oklch, var(--primary) 12%, transparent);
    outline: 0;
}

.dream-chat-tools {
    display: flex;
    gap: 7px;
    padding: 10px 12px 6px;
    border-top: 1px solid var(--line);
}

.dream-chat-tools input {
    display: none;
}

.dream-chat-tools button.active {
    color: #fff;
    border-color: transparent;
    background: #10a87b;
    box-shadow: 0 0 0 4px rgba(16, 168, 123, .16);
}

.dream-chat-tools button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.dream-chat-tools [data-chat-voice].active svg {
    animation: dream-chat-voice-pulse 1.2s ease-in-out infinite;
}

@keyframes dream-chat-voice-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.dream-chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 8px;
    padding: 0 12px 8px;
}

.dream-chat-form textarea {
    width: 100%;
    min-height: 64px;
    max-height: 116px;
    resize: none;
    padding: 13px 16px;
    border: 1px solid color-mix(in oklch, var(--line) 82%, transparent);
    border-radius: 24px;
    color: var(--text);
    background: color-mix(in oklch, var(--card-solid) 92%, transparent);
    font: inherit;
    line-height: 1.45;
    outline: 0;
}

.dream-chat-form button {
    align-self: center;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: #10a87b;
    cursor: pointer;
}

.dream-chat-form button:disabled {
    opacity: .6;
    cursor: wait;
}

.dream-chat-tip,
.dream-chat-popout {
    margin: 0;
    padding: 0 12px 7px;
    color: var(--text-soft);
    text-align: center;
    font-size: 12px;
    line-height: 1.4;
}

.dream-chat-popout {
    padding-bottom: 10px;
}

.dream-chat-page-body {
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    background: #f7f8fb;
}

.dream-chat-app {
    color: var(--text);
}

.dream-chat-full {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 232px;
    width: 100vw;
    height: 100vh;
    background: color-mix(in oklch, var(--card-solid) 92%, #f6f7fb);
}

.dream-chat-rooms,
.dream-chat-members {
    min-height: 0;
    border-color: var(--line);
    background: color-mix(in oklch, var(--card-solid) 94%, transparent);
}

.dream-chat-rooms {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 18px 13px 14px;
    border-right: 1px solid var(--line);
}

.dream-chat-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    font-weight: 900;
}

.dream-chat-brand span {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b8cff, #5fd5be);
}

.dream-chat-room-title,
.dream-chat-member-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 800;
}

.dream-chat-room-list {
    display: grid;
    align-content: start;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
}

.dream-chat-room-list button {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 5px 8px;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-weight: 800;
}

.dream-chat-room-list button.active {
    background: color-mix(in oklch, var(--primary) 13%, var(--card-solid));
}

.dream-chat-room-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    background: #10a87b;
    font-size: 13px;
    font-weight: 900;
}

.dream-chat-room-list em {
    color: var(--text-soft);
    font-size: 12px;
    font-style: normal;
}

.dream-chat-room-list svg {
    width: 13px;
    height: 13px;
}

.dream-chat-room-actions {
    display: grid;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.dream-chat-room-actions a {
    display: grid;
    place-items: center;
    min-height: 38px;
    border-radius: 8px;
    color: #fff;
    background: #10a87b;
    font-weight: 800;
}

.dream-chat-stage {
    position: relative;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    min-width: 0;
    min-height: 0;
    background: #fff;
}

.dream-chat-full .dream-chat-list {
    padding: 28px 18px;
}

.dream-chat-connected {
    justify-self: center;
    margin: 14px 0 4px;
    padding: 8px 18px;
    border-radius: 999px;
    color: #fff;
    background: #263142;
    font-size: 13px;
    font-weight: 800;
}

.dream-chat-notice {
    min-height: 34px;
    padding: 8px 18px;
    color: #fff;
    background: #10a87b;
    font-size: 13px;
    font-weight: 800;
}

.dream-chat-full .dream-chat-tools {
    padding-inline: 18px;
}

.dream-chat-full .dream-chat-form {
    padding-inline: 18px;
}

.dream-chat-full .dream-chat-form textarea {
    min-height: 54px;
}

.dream-chat-members {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    padding: 16px 12px;
    border-left: 1px solid var(--line);
}

.dream-chat-member-list {
    display: grid;
    align-content: start;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
}

.dream-chat-member {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

.dream-chat-member strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.dream-chat-member em {
    padding: 3px 8px;
    border-radius: 999px;
    color: #c78213;
    background: #fff1d7;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.dream-chat-member em.admin {
    color: #cf2d53;
    background: #ffe0e7;
}

:root.dark .dream-chat-panel,
:root.dark .dream-chat-bubble,
:root.dark .dream-chat-emoji-panel,
:root.dark .dream-chat-tools button,
:root.dark .dream-chat-tools label,
:root.dark .dream-chat-form textarea {
    border-color: rgba(255, 255, 255, .13);
    background: rgba(31, 38, 53, .92);
}

:root.dark .dream-chat-fab {
    color: rgba(255, 255, 255, .9);
    border-color: rgba(255, 255, 255, .16);
    background:
        radial-gradient(circle at 32% 24%, rgba(255, 255, 255, .13), rgba(255, 255, 255, .04)),
        rgba(31, 38, 53, .86);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .14),
        0 14px 34px rgba(0, 0, 0, .28),
        0 0 18px rgba(16, 168, 123, .12);
}

:root.dark .dream-chat.open .dream-chat-fab {
    background: linear-gradient(135deg, #10a87b, #5e63d8);
}

@media (max-width: 560px) {
    .dream-chat {
        left: 12px;
        bottom: 14px;
    }

    .dream-chat-panel {
        width: calc(100vw - 24px);
        height: min(640px, calc(100vh - 92px));
        border-radius: 20px;
    }
}

@media (max-width: 920px) {
    .dream-chat-page-body {
        overflow: auto;
    }

    .dream-chat-full {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .dream-chat-rooms,
    .dream-chat-members {
        border: 0;
    }

    .dream-chat-rooms {
        grid-template-rows: auto auto auto;
    }

    .dream-chat-room-list {
        display: flex;
        overflow-x: auto;
    }

    .dream-chat-room-list button {
        min-width: 150px;
    }

    .dream-chat-stage {
        min-height: 72vh;
    }
}
