/* Hide 📎 chip text when attachment renderer (player/image/card) is present */
.message-text.attachment-chip-text {
    display: none;
}

/* Chat Image Messages */
.image-message {
    margin: 8px 0;
    max-width: 300px;
}

.image-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-image {
    max-width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-image:hover {
    transform: scale(1.02);
}

.chat-image.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1000;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.image-info {
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    font-size: 12px;
    color: var(--secondary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-filename {
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    flex: 1;
}

.image-size {
    font-size: 11px;
    opacity: 0.8;
}

/* Search highlighting */
mark {
    background-color: var(--highlight-color);
    color: var(--text-color);
    padding: 1px 2px;
    border-radius: 2px;
}

/* Reaction picker */
.reaction-picker {
    position: fixed;
    background: var(--fieldset-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 4px;
    z-index: 1000;
}

.reaction-option {
    background: none;
    border: none;
    font-size: 20px;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.reaction-option:hover {
    background-color: var(--bg-color);
}

/* Chat header search */
.chat-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-header-controls .search-option {
    white-space: nowrap;
    font-size: 13px;
    cursor: pointer;
}

.search-container {
    position: relative;
    width: 200px;
}

.search-input {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--input-border);
    border-radius: 16px;
    font-size: 14px;
    background: var(--input-bg);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search-btn:hover {
    background-color: var(--bg-color);
}

.no-search-results {
    text-align: center;
    padding: 20px;
    color: var(--secondary-color);
    font-style: italic;
}

/* Direct Messages UI */
.dm-section { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--border-color); }
.dm-header { display:flex; align-items:center; justify-content:space-between; }
.dm-header h3 { margin: 6px 0; font-size: 14px; }
.dm-search { position: relative; margin: 6px 0; }
.dm-search .search-input { width: 100%; padding: 6px 10px; border: 1px solid var(--input-border); border-radius: 12px; background: var(--input-bg); font-size: 13px; }
.dm-search-results { position: absolute; top: 36px; left: 0; right: 0; background: var(--fieldset-bg); border: 1px solid var(--border-color); z-index: 5; max-height: 220px; overflow-y: auto; border-radius: 6px; }
.dm-result-item { padding: 6px 10px; cursor: pointer; }
.dm-result-item:hover { background: var(--bg-color); }
.dm-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.dm-item .dm-open { width: 100%; text-align: left; background: transparent; border: 1px solid var(--border-color); border-radius: 8px; padding: 6px 8px; cursor: pointer; display: flex; align-items: center; gap: 6px; color: inherit; font-size: 13px; }
.dm-item .dm-open:hover { background: var(--bg-color); }
.dm-item .dm-icon { margin-right: 6px; }

/* External media embeds */
.chat-embed {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary, #f4f6f8);
    position: relative;
}

.chat-embed-placeholder {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-primary);
    min-height: 160px;
    background: rgba(0, 0, 0, 0.65);
}

.chat-embed-thumb {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    max-height: 320px;
}

.chat-embed-thumb.stub {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    letter-spacing: 1px;
    background: color-mix(in srgb, var(--primary-color) 80%, #000);
    min-height: 160px;
}

.chat-embed-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 12px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.65) 100%);
    pointer-events: none;
}

.chat-embed-provider {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    opacity: 0.9;
}

.chat-embed-button {
    font-size: 12px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 999px;
    padding: 6px 12px;
    pointer-events: none;
}

.media-embed-frame {
    width: 100%;
    min-height: 220px;
    border: none;
    background: var(--video-bg);
}

.chat-embed-error {
    padding: 12px;
    background: var(--border-color);
    border-radius: 6px;
    text-align: center;
}

.chat-embed-retry-btn {
    margin-top: 8px;
    padding: 4px 12px;
    border: 1px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
}

.link-preview-embed {
    margin-top: 8px;
}

/* Text room styling */
.text-only-room .room-button {
    background: color-mix(in srgb, var(--primary-color) 70%, var(--secondary-color));
    color: var(--text-on-primary);
}

.hybrid-room .room-button {
    background: color-mix(in srgb, var(--primary-color) 50%, var(--error-color));
    color: var(--text-on-primary);
}

.room-button.active {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.room-info {
    font-size: 11px;
    opacity: 0.8;
    margin-left: auto;
}

/* Message reaction controls */
.message-reaction-controls {
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-item:hover .message-reaction-controls {
    opacity: 1;
}

.add-reaction-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 12px;
    cursor: pointer;
    color: var(--secondary-color);
    transition: all 0.2s;
}

.add-reaction-btn:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.message-reactions {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    background: transparent;
    border: none;
    font-size: 13px;
    cursor: pointer;
    color: inherit;
    opacity: 0.72;
    transition: color 0.2s, opacity 0.2s;
}

.reaction:hover {
    background: transparent;
    border-color: transparent;
    opacity: 1;
}

/* Inline link preview (from MessageRenderer._renderLinkPreview) */
.message-link-preview {
    margin-top: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 8px 12px;
}

/* Link Previews */
.message-link-previews {
    margin-top: 8px;
    margin-bottom: 4px;
}

.link-preview {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 4px 0;
    overflow: hidden;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 400px;
}

.link-preview:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.link-preview.loading {
    border-color: var(--secondary-color);
    cursor: default;
}

.link-preview.error {
    border-color: var(--error-color);
    cursor: default;
}

.link-preview-content {
    display: flex;
    align-items: flex-start;
}

.link-preview-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    overflow: hidden;
    background: var(--bg-color);
}

.link-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-preview-text {
    flex: 1;
    padding: 12px;
    min-width: 0;
}

.link-preview-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-preview-description {
    color: var(--secondary-color);
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-preview-url {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--secondary-color);
    font-size: 12px;
    text-decoration: none;
}

.link-preview-url:hover {
    color: var(--primary-color);
}

.link-preview-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--secondary-color);
}

.link-preview-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--error-color);
}

/* File Attachments */
.message-attachments {
    margin-top: 8px;
    margin-bottom: 4px;
}

.file-attachment {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 4px 0;
    overflow: hidden;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
    max-width: 400px;
}

.file-attachment:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-attachment.loading {
    border-color: var(--secondary-color);
}

.file-attachment.error {
    border-color: var(--error-color);
}

.file-attachment-content {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 12px;
}

.file-attachment-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: var(--text-on-primary);
    border-radius: 6px;
    font-size: 18px;
}

.file-attachment-info {
    flex: 1;
    min-width: 0;
}

.file-attachment-name {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-attachment-details {
    display: flex;
    gap: 8px;
    color: var(--secondary-color);
    font-size: 12px;
}

.file-attachment-size {
    color: var(--secondary-color);
    font-size: 12px;
}

.file-attachment-type {
    color: var(--secondary-color);
    font-size: 12px;
}

.file-attachment-error {
    color: var(--error-color);
    font-size: 12px;
}

.file-attachment-actions {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
}

.file-download-btn, .file-view-btn {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
    text-decoration: none;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.file-download-btn:hover, .file-view-btn:hover {
    background: var(--primary-color);
    color: var(--text-on-primary);
    border-color: var(--primary-color);
}

/* Inline Image Attachments (from MessageRenderer image rendering) */
.image-attachment-wrap {
    position: relative;
    display: inline-block;
    max-width: 400px;
    margin: 4px 0;
}

.inline-image {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: pointer;
}

.inline-image.custom-emoji {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    max-width: none;
    object-fit: contain;
    margin: 0 1px;
    vertical-align: text-bottom;
    cursor: default;
}

.reaction .inline-image.custom-emoji {
    width: 16px;
    height: 16px;
    margin-right: 4px;
}

.reaction .custom-emoji-count {
    margin-left: 2px;
}

.image-download-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 14px;
}

.image-attachment-wrap:hover .image-download-btn {
    opacity: 1;
}

.image-download-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Media Attachments (audio/video from ChatUICore) */
.media-attachment {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    max-width: 500px;
}

.media-attachment-player {
    width: 100%;
}

.media-attachment-info {
    flex: 1;
    padding: 4px 0;
    font-size: 13px;
    color: var(--secondary-color);
}

.media-attachment-actions {
    display: flex;
    gap: 4px;
}

.media-attachment-actions .file-download-btn {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.media-attachment:hover .media-attachment-actions .file-download-btn {
    opacity: 1;
}

.media-attachment-actions .file-download-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border-color: transparent;
}

.media-attachment-error {
    padding: 8px 0;
    font-size: 13px;
    color: var(--secondary-color);
}

/* Image File Attachments */
.file-attachment.image {
    max-width: 300px;
}

.file-attachment-thumbnail {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.attachment-image {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
    max-height: 200px;
    object-fit: cover;
}

.attachment-image:hover {
    transform: scale(1.02);
}

.attachment-image.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1000;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-height: none;
    object-fit: contain;
}

/* Loading States */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.file-attachment-progress {
    margin-top: 8px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { width: 0%; }
    50% { width: 100%; }
}

/* Dark Theme Compatibility */
[data-theme="dark"] .link-preview,
[data-theme="dark"] .file-attachment {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .link-preview:hover,
[data-theme="dark"] .file-attachment:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

[data-theme="dark"] .link-preview-image,
[data-theme="dark"] .file-attachment-icon {
    background: rgba(255, 255, 255, 0.1);
}

/* Light Theme Compatibility */
[data-theme="light"] .link-preview,
[data-theme="light"] .file-attachment {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .link-preview:hover,
[data-theme="light"] .file-attachment:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .link-preview,
    .file-attachment {
        max-width: 100%;
    }
    
    .link-preview-content {
        flex-direction: column;
    }
    
    .link-preview-image {
        width: 100%;
        height: 120px;
    }
    
    .file-attachment-content {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .file-attachment-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .attachment-image.expanded {
        max-width: 95vw;
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .link-preview-text,
    .file-attachment-content {
        padding: 8px;
    }

    .link-preview-title,
    .file-attachment-name {
        font-size: 14px;
    }

    .link-preview-description {
        font-size: 12px;
    }

    .file-attachment-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

/* Poll widget */
.poll-widget {
    padding: 8px;
    background: var(--bg-secondary);
    margin: 4px 0;
}

.poll-question {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.poll-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.poll-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font: inherit;
    text-align: left;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.15s;
}

.poll-option:hover {
    border-color: var(--primary-color);
}

.poll-option.voted {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 15%, var(--bg-color));
}

.poll-option-indicator {
    flex-shrink: 0;
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.poll-option-text {
    flex: 1;
    font-size: 13px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poll-option-bar-wrap {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    position: relative;
}

.poll-option-bar {
    height: 4px;
    background: var(--primary-color);
    transition: width 0.3s;
}

.poll-option-count {
    font-size: 11px;
    color: var(--text-light);
    min-width: 48px;
    text-align: right;
    flex-shrink: 0;
}

.poll-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-light);
}

.poll-status-closed {
    font-weight: 600;
    color: var(--secondary-color);
}

.poll-closed {
    opacity: 0.7;
}

.poll-closed .poll-option {
    cursor: default;
}

.poll-closed .poll-option:hover {
    border-color: transparent;
}

/* Emoji management panel */
.emoji-mgmt-panel {
    padding: 8px 0;
}

.emoji-mgmt-panel h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.emoji-upload-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.emoji-shortcode-input {
    padding: 4px 8px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 13px;
    flex: 1;
}

.emoji-upload-status {
    font-size: 12px;
    margin-bottom: 4px;
    min-height: 16px;
}

.emoji-upload-status.error {
    color: var(--error-color);
}

.emoji-upload-status.success {
    color: var(--success-color);
}

.emoji-upload-status.info {
    color: var(--text-light);
}

.emoji-catalog-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.emoji-catalog-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    font-size: 12px;
}

.emoji-catalog-item img {
    flex-shrink: 0;
}

.emoji-shortcode {
    color: var(--text-light);
}

.emoji-delete-btn {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.emoji-delete-btn:hover {
    opacity: 1;
}

.emoji-empty {
    color: var(--text-light);
    font-size: 12px;
    font-style: italic;
}

/* @Mention Highlighting — uses CSS vars for automatic theme adaptation */
.mention {
    background-color: color-mix(in srgb, var(--mention-color) 15%, transparent);
    color: var(--mention-color);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.mention:hover {
    background-color: color-mix(in srgb, var(--mention-color) 30%, transparent);
}

/* Self-mention highlighting (when you are mentioned) */
.mention-self {
    background-color: color-mix(in srgb, var(--mention-self-color) 25%, transparent);
    color: var(--mention-self-color);
}

.mention-self:hover {
    background-color: color-mix(in srgb, var(--mention-self-color) 40%, transparent);
}

/* Reaction toggle: highlight chips the current user has reacted with */
.reaction.aggregated.user-reacted {
    background: transparent;
    border-color: transparent;
    color: var(--primary-color);
    opacity: 1;
}

.reaction.aggregated.user-reacted:hover {
    background: transparent;
}

/* Quote reply block (inline in message) */
.quote-reply-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    margin: 4px 0 6px;
    border-left: 3px solid var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 8%, transparent);
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background-color 0.2s;
    max-width: 400px;
}

.quote-reply-block:hover {
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
}

.quote-reply-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
}

.quote-reply-text {
    font-size: 13px;
    color: var(--secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Reply button in hover controls */
.reply-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 12px;
    cursor: pointer;
    color: var(--secondary-color);
    transition: all 0.2s;
    margin-right: 4px;
}

.reply-btn:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Quote preview bar above editor */
.quote-preview-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: color-mix(in srgb, var(--primary-color) 8%, transparent);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px 4px 0 0;
    font-size: 13px;
}

.quote-preview-label {
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.quote-preview-text {
    color: var(--secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.quote-preview-close {
    background: none;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.quote-preview-close:hover {
    background: var(--hover-bg);
    color: var(--text-color);
}

/* Highlight flash animation for scroll-to-quote */
@keyframes highlightFlash {
    0% { background-color: color-mix(in srgb, var(--primary-color) 25%, transparent); }
    100% { background-color: transparent; }
}

.highlight-flash {
    animation: highlightFlash 1.5s ease-out;
}

.forum-root {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(220px, 320px) minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    background: var(--bg-color);
    color: var(--text-color);
}

.forum-boards-panel,
.forum-threads-panel,
.forum-detail-panel {
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.forum-detail-panel {
    border-right: 0;
}

.forum-panel-header,
.forum-thread-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.forum-panel-header h3,
.forum-thread-header h3 {
    margin: 0;
    font-size: 14px;
    line-height: 1.25;
}

.forum-unread-badge {
    min-width: 20px;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--primary-color);
    color: var(--button-text-color, #fff);
    font-size: 12px;
    text-align: center;
}

.forum-board-list,
.forum-thread-list,
.forum-message-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.forum-board-row,
.forum-thread-row {
    width: 100%;
    display: block;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    padding: 9px 12px;
    cursor: pointer;
}

.forum-board-row.active,
.forum-thread-row.active,
.forum-board-row:hover,
.forum-thread-row:hover {
    background: var(--hover-bg);
}

.forum-board-name,
.forum-thread-title {
    display: block;
    overflow-wrap: anywhere;
    font-weight: 600;
}

.forum-thread-meta {
    color: var(--status-text-color);
    font-size: 12px;
    line-height: 1.4;
}

.forum-thread-badges {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
}

.forum-thread-badge {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 11px;
    color: var(--status-text-color);
}

.forum-inline-form,
.forum-thread-form,
.forum-reply-form,
.forum-poll-form {
    flex: 0 0 auto;
    display: grid;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
}

.forum-inline-form {
    grid-template-columns: minmax(0, 1fr) auto;
}

.forum-thread-form textarea,
.forum-reply-form textarea,
.forum-poll-form textarea {
    min-height: 72px;
    resize: vertical;
}

.forum-message-list {
    padding: 8px 12px;
}

.forum-message-list .message-item {
    margin-bottom: 8px;
}

.forum-thread-actions {
    display: inline-flex;
    gap: 6px;
}

.forum-poll-reply {
    flex: 0 0 auto;
    border-top: 1px solid var(--border-color);
    padding: 8px 12px;
}

@media (max-width: 900px) {
    .forum-root {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(0, 1fr);
    }

    .forum-boards-panel,
    .forum-threads-panel {
        max-height: 180px;
    }
}
