.v3-chat-room {
    --chat-border: #3b3536;
    --chat-muted: #b2aaa7;
    --chat-accent: #ffc18f;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    background: #171619;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .16);
}

.v3-chat-room-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--chat-border);
    background: linear-gradient(104deg, #2a201b, #211b1d 68%, #1f1a1d);
}
.v3-chat-room-title { min-width: 0; }
.v3-chat-room-title h2 { margin: 0; font-size: 17px; line-height: 1.3; }
.v3-chat-connection {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
    margin-inline-start: auto;
    color: #b4ddc4;
    font-size: 12px;
    text-align: end;
}
.v3-chat-connection::before {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: currentColor;
    content: '';
}
.v3-chat-connection:not([data-state="connected"]) { color: var(--chat-accent); }

.v3-chat-history { position: relative; }
.v3-chat-scroller {
    height: clamp(202px, calc(100dvh - 460px), 595px);
    overflow: auto;
    overscroll-behavior: contain;
    overflow-anchor: none;
    scrollbar-width: thin;
    scrollbar-color: #67554d #18171a;
}
.v3-chat-scroller:focus-visible { outline-offset: -2px; }
.v3-chat-empty {
    display: grid;
    min-height: 100%;
    place-content: center;
    justify-items: center;
    gap: 5px;
    margin: 0;
    padding: 20px;
    color: var(--chat-muted);
    text-align: center;
}
.v3-chat-empty svg { width: 28px; height: 28px; margin-bottom: 4px; color: var(--chat-accent); }
.v3-chat-empty strong { color: #f4efec; font-size: 16px; }

.v3-chat-load-older {
    display: block;
    min-height: 36px;
    margin: 8px auto 2px;
    padding: 5px 12px;
    border: 1px solid #514442;
    border-radius: 7px;
    background: #252122;
    color: #e8c9b7;
    font-size: 12px;
}
.v3-chat-load-older:hover:not(:disabled) { background: #332927; }
.v3-chat-load-older:disabled { opacity: .65; }
.v3-chat-load-older[hidden] { display: none; }

.v3-chat-messages { display: grid; padding: 6px 20px; margin: 0; list-style: none; }
.v3-chat-empty:not([hidden]) + [role="log"] .v3-chat-messages { padding: 0; }
.v3-chat-message {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 11px;
    min-width: 0;
    padding: 12px 0;
}
.v3-chat-message + .v3-chat-message { border-top: 1px solid #2b282a; }
.v3-chat-avatar {
    display: block;
    width: 38px;
    height: 38px;
    border: var(--cosmetic-avatar-border-width, 1px) solid #514442;
    border-radius: 50%;
    background: #2d2525;
    object-fit: cover;
}
.v3-chat-message-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; }
.v3-chat-message-meta .v3-chat-author { color: var(--chat-accent); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.v3-chat-message-meta a[href]:hover { text-decoration: underline; }
.v3-chat-staff-badge { padding: 1px 6px; border: 1px solid #9c6b28; border-radius: 999px; background: #3a2b18; color: #ffd27a; font-size: 10px; font-weight: 700; line-height: 1.5; }
.v3-chat-ban-items { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.v3-chat-ban-items li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #383235; }
.v3-chat-ban-items li > span { min-width: 0; overflow-wrap: anywhere; }
.v3-chat-ban-items button { flex: 0 0 auto; }
.v3-chat-level {
    padding: 1px 5px;
    border: 1px solid #726497;
    border-radius: 4px;
    background: #2b2238;
    color: #e2d4ff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
    white-space: nowrap;
}
.v3-chat-message-meta .v3-chat-badges { margin: 0; }
.v3-chat-message-meta .v3-chat-badges img { width: 20px; height: 20px; }
.v3-chat-message-meta [hidden] { display: none; }
.v3-chat-message-meta time { color: var(--chat-muted); font-size: 11px; }
.v3-chat-message-text { margin-top: 3px; color: #f0eae7; white-space: pre-wrap; overflow-wrap: anywhere; }
.v3-chat-room .v3-chat-message [data-chat-delete] button {
    min-width: 44px;
    min-height: 38px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--chat-muted);
    font-size: 12px;
}
.v3-chat-message [data-chat-delete] button:hover { border-color: #674a4b; background: #2d2225; color: #ffbdc0; }
.v3-chat-room .v3-chat-latest {
    position: absolute;
    right: 16px;
    bottom: 12px;
    min-height: 42px;
    padding-inline: 12px;
    border: 1px solid #845b46;
    border-radius: 8px;
    background: #3b2921;
    color: #ffdbc0;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 4px 14px #100d0e9c;
}
.v3-chat-latest:hover { background: #4e3427; }

.v3-chat-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--chat-border);
    background: #211c1d;
}
.v3-chat-feedback, .v3-chat-success, .v3-chat-restriction {
    margin: 0 0 9px;
    font-size: 13px;
    overflow-wrap: anywhere;
}
.v3-chat-feedback { color: #ffb7be; }
.v3-chat-success { color: #b4ddc4; }
.v3-chat-restriction { color: var(--chat-accent); }
.v3-chat-composer { display: grid; gap: 8px; }
.v3-chat-composer textarea {
    width: 100%;
    min-height: 64px;
    max-height: 180px;
    padding: 9px 12px;
    resize: vertical;
    border: 1px solid #585050;
    border-radius: 8px;
    background: #161517;
    color: #fff9f6;
    font: inherit;
}
.v3-chat-composer textarea::placeholder { color: var(--chat-muted); }
.v3-chat-composer textarea:focus-visible { outline-offset: 1px; }
.v3-chat-composer textarea:disabled { opacity: .65; }
.v3-chat-composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.v3-chat-character-count { color: var(--chat-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.v3-chat-room .v3-chat-send {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 8px;
    padding: 0 15px;
    border: 1px solid #ff9d53;
    border-radius: 8px;
    background: #f58c48;
    color: #20130b;
    font-size: 14px;
    font-weight: 750;
}
.v3-chat-send:hover:not(:disabled) { background: #ffad72; }
.v3-chat-send:disabled, .v3-chat-message button:disabled { cursor: default; opacity: .5; }
.v3-chat-send svg { width: 16px; height: 16px; }

@media (max-width: 760px) {
    .v3-chat-room-heading { gap: 9px; padding: 11px; }
    .v3-chat-room-title h2 { font-size: 15px; }
    .v3-chat-connection { max-width: 100px; gap: 5px; font-size: 11px; }
    .v3-chat-scroller { height: clamp(176px, calc(100dvh - 470px), 500px); }
    .v3-chat-messages, .v3-chat-actions { padding-inline: 11px; }
    .v3-chat-message { gap: 8px; }
    .v3-chat-avatar { width: 33px; height: 33px; }
    .v3-chat-room .v3-chat-message [data-chat-delete] button { min-height: 44px; }
    .v3-chat-message-text { font-size: 14px; }
    .v3-chat-composer textarea { font-size: 16px; }
}

.v3-chat-room [hidden] { display: none !important; }

.v3-chat-message.is-highlighted {
    border-radius: 4px;
    background: color-mix(in srgb, var(--chat-accent) 12%, transparent);
    box-shadow: inset 2px 0 var(--chat-accent);
}

.v3-chat-quote, .v3-chat-composer-quote {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: baseline;
    gap: 7px;
    padding: 4px 8px;
    border: 0;
    border-inline-start: 2px solid var(--chat-accent);
    border-radius: 0 4px 4px 0;
    background: color-mix(in srgb, var(--chat-accent) 7%, transparent);
    color: var(--chat-muted);
    font-size: 12px;
    line-height: 1.35;
    text-align: start;
}
.v3-chat-quote { max-width: 50ch; margin-top: 5px; }
.v3-chat-quote:hover { background: color-mix(in srgb, var(--chat-accent) 15%, transparent); color: inherit; }
.v3-chat-quote strong, .v3-chat-quote > span,
.v3-chat-composer-quote strong, .v3-chat-composer-quote span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v3-chat-quote strong, .v3-chat-composer-quote strong { color: var(--chat-accent); }
.v3-chat-quote strong { flex: 0 1 auto; max-width: 36%; }
.v3-chat-composer-quote { grid-column: 1 / -1; align-items: center; justify-content: space-between; }
.v3-chat-composer-quote > div { display: flex; min-width: 0; gap: 8px; }
.v3-chat-composer-quote button { flex: none; }

.v3-chat-spoiler {
    display: inline-block;
    box-sizing: border-box;
    max-inline-size: 100%;
    overflow: hidden;
    padding: 0 6px;
    border: 0;
    border-radius: 4px;
    background: #282330;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: start;
    white-space: inherit;
    overflow-wrap: inherit;
    vertical-align: middle;
    cursor: pointer;
}
.v3-chat-spoiler:focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 2px; }
.v3-chat-spoiler-text { display: block; }
.v3-chat-spoiler[aria-expanded="false"] {
    user-select: none;
}
.v3-chat-spoiler[aria-expanded="false"] .v3-chat-spoiler-text {
    filter: blur(8px);
    opacity: .72;
}

.v3-chat-share {
    display: flex;
    width: fit-content;
    max-width: 100%;
    min-height: 38px;
    align-items: center;
    gap: 9px;
    margin-top: 6px;
    padding: 4px 9px 4px 4px;
    border: 1px solid var(--chat-border);
    border-radius: 5px;
    background: color-mix(in srgb, var(--chat-accent) 6%, transparent);
    color: #f4f0f8;
    text-decoration: none;
}
.v3-chat-share:hover { border-color: var(--chat-accent); }
.v3-chat-share img { display: block; width: 35px; height: 49px; flex: none; border-radius: 3px; object-fit: cover; }
.v3-chat-share-copy { display: grid; min-width: 0; gap: 1px; padding: 0 2px; }
.v3-chat-share-copy > * { min-width: 0; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.v3-chat-share-copy > span { color: var(--chat-muted); }
.v3-chat-share-action { flex: none; margin-inline-start: auto; color: var(--chat-accent); font-size: 11px; font-weight: 650; }

.v3-chat-message-actions { display: flex; align-items: center; gap: 4px; }
.v3-chat-reactions, .v3-chat-reaction-options {
    display: flex;
    min-width: 0;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.v3-chat-reactions { margin-top: 4px; }

.v3-chat-reactions button, .v3-chat-message-menu button, .v3-chat-message-menu-trigger,
.v3-chat-composer-quote button, .v3-chat-topic button {
    min-height: 24px;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--chat-muted);
    font: inherit;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.35;
}
.v3-chat-reactions button { border-color: var(--chat-border); border-radius: 999px; }
.v3-chat-reactions button:is(:hover, [aria-pressed="true"]),
.v3-chat-message-menu button:is(:hover, [aria-pressed="true"]), .v3-chat-message-menu-trigger:hover,
.v3-chat-topic button:hover, .v3-chat-composer-quote button:hover {
    border-color: var(--chat-border);
    background: color-mix(in srgb, var(--chat-accent) 12%, transparent);
    color: var(--chat-accent);
}
.v3-chat-message-menu-trigger { width: 32px; min-height: 28px; padding: 0; font-size: 18px; }
.v3-chat-room:has(.v3-chat-composer textarea:disabled) .v3-chat-message:not([data-chat-can-timeout="true"]) .v3-chat-message-menu-trigger { display: none; }
@media (hover: hover) and (pointer: fine) {
    .v3-chat-message:not(:hover):not(:focus-within) .v3-chat-message-menu-trigger[aria-expanded="false"] { opacity: 0; }
}
.v3-chat-message-menu {
    position: fixed;
    z-index: 2;
    inset: 0 auto auto 0;
    box-sizing: border-box;
    width: min(244px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    background: #1c1a23;
    box-shadow: 0 8px 24px #0007;
}
.v3-chat-message-menu .v3-chat-menu-reply {
    width: 100%;
    min-height: 34px;
    padding-inline: 8px;
    color: #eeeaf3;
    font-size: 13px;
    text-align: start;
}
.v3-chat-reaction-label {
    margin-top: 4px;
    padding: 7px 8px 3px;
    border-top: 1px solid var(--chat-border);
    color: var(--chat-muted);
    font-size: 11px;
}
.v3-chat-reaction-options { padding: 0 4px 2px; }
.v3-chat-reaction-options button { min-width: 32px; min-height: 32px; padding-inline: 3px; font-size: 15px; }
.v3-chat-spoiler-tools { position: relative; margin-inline-end: auto; }
.v3-chat-spoiler-trigger {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 6px;
    padding-inline: 10px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    background: #1c1a23;
    color: var(--chat-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
}
.v3-chat-spoiler-trigger svg { width: 15px; height: 15px; }
.v3-chat-spoiler-trigger:is(:hover, [aria-expanded="true"]),
.v3-chat-spoiler-tools:has(input:checked) .v3-chat-spoiler-trigger {
    border-color: #645179;
    background: #282233;
    color: #f2e7fd;
}
.v3-chat-spoiler-state {
    display: none;
    padding: 1px 5px;
    border-radius: 4px;
    background: #c5b2ff24;
    font-size: 10px;
}
.v3-chat-spoiler-tools:has(input:checked) .v3-chat-spoiler-state { display: inline-block; }
.v3-chat-spoiler-options {
    position: absolute;
    z-index: 2;
    inset-inline-start: 0;
    bottom: calc(100% + 8px);
    box-sizing: border-box;
    width: min(220px, calc(100vw - 48px));
    max-height: 42dvh;
    overflow: auto;
    padding: 5px;
    border: 1px solid #474051;
    border-radius: 10px;
    background: #1c1a23;
    box-shadow: 0 8px 24px #0007;
}
.v3-chat-spoiler-options :is(button, label) {
    display: flex;
    width: 100%;
    min-height: 38px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 9px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #eeeaf3;
    font: inherit;
    font-size: 13px;
    text-align: start;
    cursor: pointer;
}
.v3-chat-spoiler-options :is(button:hover:enabled, label:hover, label:has(input:checked)) { background: #30273d; }
.v3-chat-spoiler-options :is(button:focus-visible, label:has(input:focus-visible)) {
    outline: 2px solid var(--chat-accent);
    outline-offset: -2px;
}
.v3-chat-spoiler-switch {
    display: inline-flex;
    width: 28px;
    height: 16px;
    flex: none;
    align-items: center;
    padding-inline: 2px;
    border-radius: 999px;
    background: #50465d;
}
.v3-chat-spoiler-switch::before {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ebe2f4;
    content: '';
}
.v3-chat-whole-spoiler input:checked + .v3-chat-spoiler-switch { justify-content: flex-end; background: #9474cf; }
.v3-chat-composer:has(.v3-chat-whole-spoiler input:checked) textarea { border-color: #7d6497; }
.v3-chat-spoiler-tools button:disabled { opacity: .55; cursor: default; }

.v3-chat-topic {
    display: grid;
    min-width: 0;
    gap: 5px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--chat-border);
    background: color-mix(in srgb, var(--chat-accent) 7%, #18161b);
    color: #eae5f0;
}
.v3-chat-topic-summary { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
.v3-chat-topic-summary > div { display: grid; min-width: 0; gap: 1px; font-size: 12px; }
.v3-chat-topic-summary strong { color: var(--chat-accent); font-size: 11px; }
.v3-chat-topic-summary span { overflow-wrap: anywhere; }
.v3-chat-topic-summary > button { flex: none; margin-inline-start: auto; }
.v3-chat-topic-form { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 5px; }
.v3-chat-topic-form label { flex: none; font-size: 12px; }
.v3-chat-topic-form input {
    min-width: 0;
    min-height: 32px;
    flex: 1 1 180px;
    padding: 4px 7px;
    border: 1px solid var(--chat-border);
    border-radius: 5px;
    background: #17161b;
    color: inherit;
    font: inherit;
    font-size: 13px;
}
.v3-chat-topic-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.v3-chat-topic-controls button { border-color: var(--chat-border); }
.v3-chat-topic-controls button[type="submit"] { color: var(--chat-accent); }

@media (max-width: 760px) {
    .v3-chat-reactions button { min-height: 30px; }
    .v3-chat-topic-form input { font-size: 16px; }
    .v3-chat-drawer .v3-chat-actions .v3-chat-composer { grid-template-columns: minmax(0, 1fr); }
    .v3-chat-drawer .v3-chat-actions .v3-chat-composer-footer { width: 100%; }
}

@media (pointer: coarse) {
    .v3-chat-message-menu-trigger { width: 40px; min-height: 36px; }
    .v3-chat-message-menu .v3-chat-menu-reply, .v3-chat-reaction-options button { min-height: 40px; }
    .v3-chat-spoiler-trigger, .v3-chat-spoiler-options :is(button, label) { min-height: 44px; }
}
