.radio-chat {
    --radio-chat-bottom: calc(var(--radio-chat-player-height, 80px) + 12px);
    position: fixed;
    z-index: 8;
    inset-inline-end: max(12px, env(safe-area-inset-right));
    bottom: var(--radio-chat-bottom);
    color: var(--text-main);
}

.radio-chat summary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 1.25rem;
    border: 1px solid var(--link);
    border-radius: 999px;
    background: var(--bg-color);
    box-shadow: 0 6px 22px #0004;
    color: var(--link);
    font-weight: 800;
    cursor: grab;
    touch-action: none;
    user-select: none;
    list-style: none;
}

.radio-chat[data-dragging] summary {
    cursor: grabbing;
}

.radio-chat[data-positioned] {
    inset: var(--chat-top) auto auto var(--chat-left);
}

.radio-chat[data-positioned] .radio-chat-content {
    inset-inline: auto;
    left: var(--chat-content-left);
    max-height: min(620px, var(--chat-content-space));
}

.radio-chat[data-opens-below] .radio-chat-content {
    top: calc(100% + 8px);
    bottom: auto;
}

.radio-chat summary::-webkit-details-marker {
    display: none;
}

.radio-chat summary:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 3px;
}

.radio-chat-content {
    position: absolute;
    inset-inline-end: 0;
    bottom: calc(100% + 8px);
    width: min(380px, calc(100vw - 24px));
    max-height: min(620px, calc(100dvh - var(--radio-chat-bottom) - 72px));
    overflow-y: auto;
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 12px 30px #0005;
}

.radio-chat:not([open]) .radio-chat-content {
    display: none;
}

.radio-chat form {
    display: grid;
    gap: 8px;
}

.radio-chat-rules, .radio-chat-status, .radio-chat time, .radio-chat [data-chat-empty] {
    color: var(--text-muted);
    font-size: .875rem;
    line-height: 1.3;
}

.radio-chat label {
    font-weight: 700;
}

.radio-chat-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.radio-chat input {
    flex: 1 1 120px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    color: var(--text-main);
    background: var(--bg-color);
}

.radio-chat input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.radio-chat button {
    padding: 10px 14px;
    border: 1px solid var(--link);
    border-radius: 10px;
    color: var(--link);
    background: var(--bg-color);
    font-weight: 800;
    cursor: pointer;
}

.radio-chat button:disabled {
    opacity: .6;
    cursor: default;
}

.radio-chat-error {
    color: var(--link);
}

.radio-chat :is(.radio-chat-status, .radio-chat-error, .radio-chat-messages):empty {
    display: none;
}

.radio-chat-messages {
    max-height: min(40dvh, 254px);
    overflow-y: auto;
    margin: 0;
    padding: 0 12px;
    list-style: none;
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    background: var(--bg-color);
    overflow-wrap: anywhere;
}

.radio-chat-messages li {
    padding: 10px 0;
}

.radio-chat-messages li + li {
    border-top: 1px solid var(--surface-border);
}

.radio-chat-messages strong {
    margin-right: 8px;
    color: var(--link);
}
