.home-chat-panel {
    display: flex;
    flex-direction: column;
}

.home-chat-banner {
    width: 256px;
    margin: 0 auto;
}

.home-chat-shell {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}

#chat-form,
#chat-form input,
#chat-form button,
#chat-status,
#chat-messages {
    font-family: 'PixeloidSans', 'PixelOperatorMono', 'PixeloidSans', monospace;
}

#chat-messages {
    height: 100%;
    background: #ffffff;
    color: #000000;
    border: 2px inset #dfdfdf;
    overflow-y: auto;
    padding: 4px;
    text-align: left;
    font-size: 12px;
}

.chat-messages-shell {
    position: relative;
    min-height: 180px;
    height: clamp(180px, 38vh, 360px);
    max-height: 360px;
    flex-grow: 1;
}

.chat-messages-shell::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    z-index: 2;
}

#chat-status {
    font-size: 12px;
    text-align: left;
    min-height: 1em;
}

#chat-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-author-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chat-author-label {
    font-size: 12px;
}

#chat-author,
.chat-message-input {
    flex-grow: 1;
}

#chat-form.is-cooldown {
    cursor: not-allowed;
    opacity: 0.58;
    filter: grayscale(0.35);
    border: 2px inset #a7a7a7;
    background: linear-gradient(180deg, #dadada 0%, #c8c8c8 100%);
    padding: 6px;
}

#chat-form.is-cooldown * {
    cursor: not-allowed !important;
}

#chat-cooldown-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    border: 2px outset #a9a9a9;
    background: linear-gradient(180deg, #fff1c4 0%, #ffd978 100%);
    color: #3d2b00;
    font-family: 'PixeloidSans', 'PixelOperatorMono', 'PixeloidSans', monospace;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

#chat-cooldown-indicator.active {
    display: inline-flex;
}

.chat-message-input-row {
    display: flex;
    gap: 4px;
}

.chat-emoji-toggle {
    width: 32px;
    min-width: 32px;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.chat-send-button {
    padding: 0 6px;
}

.chat-emoji-panel {
    border: 2px inset #dfdfdf;
    background: linear-gradient(180deg, #fcfcfc 0%, #e7e7e7 100%);
    max-height: 180px;
    overflow-y: auto;
    padding: 6px;
}

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

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 4px;
}

.chat-emoji-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 46px;
    border: 2px outset #d5d5d5;
    background: linear-gradient(180deg, #ffffff 0%, #efefef 100%);
    padding: 3px 2px;
    text-align: center;
    font-family: 'PixeloidSans', 'PixelOperatorMono', 'PixeloidSans', monospace;
    font-size: 10px;
    cursor: pointer;
}

.chat-emoji-item:hover {
    background: linear-gradient(180deg, #fff9dc 0%, #f5e9b0 100%);
}

.chat-emoji-item:active {
    border-style: inset;
}

.chat-emoji-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    image-rendering: pixelated;
}

.chat-emoji-name {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-inline-emoji {
    width: 16px;
    height: 16px;
    vertical-align: text-bottom;
    object-fit: contain;
    image-rendering: pixelated;
    margin: 0 1px;
}

.chat-message-pending {
    color: #666666;
    font-style: italic;
    font-size: 11px;
}

#chat-history-loader {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: stretch;
    min-height: 22px;
    border: 2px inset #b8b8b8;
    background: linear-gradient(180deg, #fff6d7 0%, #ffe39e 100%);
    color: #4a3200;
    font-family: 'PixeloidSans', 'PixelOperatorMono', monospace;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    visibility: hidden;
}

#chat-history-loader.active {
    visibility: visible;
}

@media (max-width: 700px) {
    .chat-messages-shell {
        min-height: 156px;
        height: min(34vh, 240px);
        max-height: 240px;
    }
}
