/* === Message Rendering === */

.message {
    padding: 1px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}

.message-pending {
    opacity: 0.5;
}

.message:hover {
    background: #f0f0f0;
}

.message.deleted {
    opacity: 0.5;
    font-style: italic;
}

.message-timestamp {
    color: #808080;
    margin-right: 4px;
    white-space: nowrap;
    font-size: 11px;
}

.message-author {
    font-weight: bold;
    margin-right: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.message-content {
    word-break: break-word;
    flex: 1;
    min-width: 0;
    font-weight: 600;
}

.message-content pre {
    background: var(--bg-field, #fff);
    border: 1px solid var(--border-dark, #808080);
    padding: 4px 6px;
    margin: 4px 0;
    overflow-x: auto;
    font-family: var(--font-mono, "Courier New", monospace);
    font-size: 11px;
    white-space: pre;
}

.message-content code {
    background: var(--bg-field, #fff);
    border: 1px solid var(--border-light, #dfdfdf);
    padding: 0 3px;
    font-family: var(--font-mono, "Courier New", monospace);
    font-size: 11px;
}

.message-content pre code {
    background: none;
    border: none;
    padding: 0;
}

.message-content ul,
.message-content ol {
    margin: 2px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 1px 0;
}

.message-content blockquote {
    border-left: 3px solid var(--border-dark, #808080);
    margin: 2px 0;
    padding: 2px 8px;
    color: var(--text-secondary, #444);
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 4px 0 2px;
    line-height: 1.3;
}
.message-content h1 { font-size: 1.3em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4,
.message-content h5,
.message-content h6 { font-size: 1em; }

.message-content del {
    text-decoration: line-through;
    opacity: 0.7;
}

.message-edited {
    color: #808080;
    font-size: 9px;
    font-style: italic;
    margin-left: 4px;
}

.message-actions {
    display: none;
    margin-left: auto;
    gap: 2px;
    font-size: 10px;
}

.message:hover .message-actions {
    display: flex;
}

.msg-action-btn {
    background: var(--bg-window);
    border: 1px solid var(--border-dark);
    cursor: pointer;
    padding: 0 4px;
    font-size: 10px;
    font-family: var(--font-main);
}

.msg-action-btn:hover {
    background: var(--border-light);
}

/* === Reply Quote === */

.reply-quote {
    border-left: 2px solid #808080;
    padding: 1px 6px;
    margin-bottom: 1px;
    font-size: 10px;
    color: #606060;
    cursor: pointer;
    background: #f4f4f4;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-quote:hover {
    background: #e8e8e8;
}

/* === Mentions === */

.mention {
    background: var(--color-mention-bg);
    border: 1px solid var(--color-mention-border);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: bold;
    cursor: pointer;
}

.mention.mention-self {
    background: #ffe0e0;
    border-color: #cc6666;
}

/* === Mention Dropdown === */

.mention-dropdown {
    position: fixed;
    background: var(--bg-field);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    max-height: 150px;
    overflow-y: auto;
    z-index: 200;
    min-width: 150px;
}

.mention-dropdown ul {
    list-style: none;
}

.mention-dropdown li {
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
}

.mention-dropdown li:hover,
.mention-dropdown li.selected {
    background: #000080;
    color: #fff;
}

/* === Reactions === */

.reactions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 1px;
    margin-left: 60px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 4px;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    font-size: 10px;
    cursor: pointer;
    user-select: none;
}

.reaction-pill:hover {
    background: var(--border-light);
}

.reaction-pill.own {
    background: #d0d0ff;
}

.reaction-pill .reaction-emoji {
    font-size: 12px;
}

.reaction-pill .reaction-count {
    font-weight: bold;
}

/* === Reaction Picker === */

.reaction-picker {
    position: fixed;
    background: var(--bg-field);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    padding: 4px;
    z-index: 200;
    max-width: calc(100vw - 8px);
    max-height: calc(100vh - 8px);
    overflow-y: auto;
}

.reaction-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.reaction-grid button {
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.reaction-grid button:hover {
    background: #000080;
    border-color: var(--border-dark);
    border-radius: 2px;
}

/* === Image Messages === */

.message-image {
    max-width: 300px;
    max-height: 200px;
    cursor: pointer;
    box-shadow: var(--bevel-in);
    margin-top: 2px;
    display: block;
}

.message-image:hover {
    opacity: 0.9;
}

/* === Link Previews === */

.link-preview {
    display: flex;
    gap: 6px;
    margin: 2px 0 2px 60px;
    padding: 4px 6px;
    background: var(--bg-window);
    box-shadow: var(--bevel-in);
    border-left: 3px solid #000080;
    max-width: 400px;
    font-size: 10px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.link-preview:hover {
    background: var(--bg-field);
}

.link-preview-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: var(--bevel-in);
}

.link-preview-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.link-preview-site {
    color: #808080;
    font-size: 9px;
    text-transform: uppercase;
    margin-bottom: 1px;
}

.link-preview-title {
    font-weight: bold;
    color: #000080;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-preview-desc {
    color: #404040;
    font-size: 10px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* === Audio Messages === */

.audio-player {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-window);
    box-shadow: var(--bevel-in);
    padding: 2px 6px;
    margin-top: 2px;
    max-width: 250px;
}

.audio-player button {
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-progress {
    flex: 1;
    height: 8px;
    background: var(--bg-field);
    box-shadow: var(--bevel-in);
    position: relative;
    cursor: pointer;
}

.audio-progress-bar {
    height: 100%;
    background: #000080;
    width: 0%;
    transition: width 0.1s;
}

.audio-time {
    font-size: 9px;
    color: var(--text-secondary);
    min-width: 30px;
    text-align: right;
}

/* === Lightbox === */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-img {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 24px;
    height: 24px;
    font-size: 16px;
    cursor: pointer;
    z-index: 2;
}

/* === Recording Indicator === */

.recording-indicator {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    padding: 4px 12px;
    font-size: 11px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 6px;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background: #cc0000;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* === New Messages Divider === */

.new-messages-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cc0000;
    font-size: 10px;
    font-weight: bold;
    padding: 4px 0;
    user-select: none;
}

.new-messages-divider::before,
.new-messages-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #cc0000;
}

/* === System Messages === */

.message-system {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2px 0;
    font-size: 10px;
}

/* === Loading === */

.loading-indicator {
    text-align: center;
    padding: 8px;
    color: var(--text-secondary);
    font-style: italic;
}

/* === Nudge === */

.nudge-shake {
    animation: nudgeShake 0.4s ease-in-out 3;
}

@keyframes nudgeShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-6px, -3px); }
    20% { transform: translate(5px, 4px); }
    30% { transform: translate(-4px, 2px); }
    40% { transform: translate(6px, -4px); }
    50% { transform: translate(-3px, 5px); }
    60% { transform: translate(4px, -2px); }
    70% { transform: translate(-5px, 3px); }
    80% { transform: translate(3px, -5px); }
    90% { transform: translate(-2px, 4px); }
}

.nudge-message {
    text-align: center;
    color: #cc6600;
    font-weight: bold;
    font-style: italic;
    padding: 2px 0;
    font-size: 11px;
}

/* === Buddy Listening Status === */

.buddy-listening {
    font-style: italic;
    color: #660099;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-item:hover .buddy-listening,
.sidebar-item.active .buddy-listening {
    color: #cc99ff;
}

.buddy-away,
.buddy-bio {
    font-style: italic;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.buddy-away {
    color: #996600;
}

.buddy-bio {
    color: #666666;
}

.sidebar-item:hover .buddy-away,
.sidebar-item.active .buddy-away {
    color: #ffcc66;
}

.sidebar-item:hover .buddy-bio,
.sidebar-item.active .buddy-bio {
    color: #cccccc;
}

/* === Radio Panel === */

.radio-panel {
    background: var(--bg-field);
    padding: 4px;
}

.radio-now-playing {
    padding: 3px 6px;
    background: #000;
    color: #00ff00;
    font-family: var(--font-mono);
    font-size: 10px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
}

.radio-status {
    display: inline-block;
}

.radio-status.scrolling {
    animation: radio-scroll 8s ease-in-out infinite alternate;
}

@keyframes radio-scroll {
    0%, 20% { transform: translateX(0); }
    80%, 100% { transform: translateX(var(--scroll-dist)); }
}

.radio-controls {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 0;
    margin-bottom: 3px;
}

.radio-btn {
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 22px;
    height: 20px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.radio-btn:active {
    box-shadow: var(--bevel-in);
}

.radio-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.radio-volume {
    flex: 1;
    height: 12px;
    cursor: pointer;
}

.radio-station-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
}

.radio-station {
    padding: 2px 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    border-bottom: 1px solid var(--border-light);
}

.radio-station:hover {
    background: #000080;
    color: #fff;
}

.radio-station.active {
    background: #000080;
    color: #fff;
}

.station-name {
    font-weight: bold;
}

.station-genre {
    color: var(--text-secondary);
    font-size: 9px;
}

.radio-station:hover .station-genre,
.radio-station.active .station-genre {
    color: #aaa;
}

/* === Emoticons === */

.emoticon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    image-rendering: pixelated;
}

.emoticon-picker {
    position: fixed;
    background: var(--bg-field);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    padding: 4px;
    z-index: 200;
    max-width: 260px;
    max-height: 200px;
    overflow-y: auto;
}

.emoticon-pack-header {
    font-size: 9px;
    font-weight: bold;
    color: var(--text-secondary);
    padding: 2px 4px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 2px;
}

.emoticon-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-bottom: 4px;
}

.emoticon-btn {
    width: 26px;
    height: 26px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.emoticon-btn:hover {
    background: #000080;
    border-color: var(--border-dark);
    border-radius: 2px;
}

.emoticon-empty {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 8px;
    text-align: center;
    font-style: italic;
}

/* === Room Topic Bar === */

.topic-bar {
    display: flex;
    align-items: center;
    padding: 2px 6px;
    background: var(--bg-field);
    border-bottom: 1px solid var(--border-dark);
    font-size: 10px;
    min-height: 18px;
    gap: 4px;
}

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

.topic-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 0 2px;
    flex-shrink: 0;
}

.topic-edit-btn:hover {
    color: var(--text-primary);
}

/* === Message Search === */

.search-panel {
    border-bottom: 1px solid var(--border-dark);
    background: var(--bg-window);
    max-height: 50%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    align-items: center;
}

.search-bar .retro-input {
    flex: 1;
}

.search-results {
    overflow-y: auto;
    flex: 1;
    padding: 0 4px 4px;
}

.search-hint,
.search-loading {
    text-align: center;
    padding: 8px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 10px;
}

.search-count {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 2px 4px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 2px;
}

.search-result {
    padding: 4px 6px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 11px;
}

.search-result:hover {
    background: var(--bg-field);
}

.search-result-header {
    display: flex;
    gap: 6px;
    align-items: baseline;
    margin-bottom: 1px;
}

.search-result-author {
    font-weight: bold;
    font-size: 11px;
}

.search-result-where {
    color: var(--text-secondary);
    font-size: 10px;
}

.search-result-time {
    color: var(--text-secondary);
    font-size: 9px;
    margin-left: auto;
}

.search-result-content {
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.search-highlight {
    background: #ffff00;
    color: #000;
    padding: 0 1px;
}

/* === Profile Card === */

.profile-card {
    position: fixed;
    z-index: 300;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    width: 220px;
    font-size: 11px;
}

.profile-card-inner {
    display: flex;
    gap: 8px;
    padding: 8px;
}

.profile-card-avatar {
    flex-shrink: 0;
}

.profile-card-avatar img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    box-shadow: var(--bevel-in);
}

.profile-card-no-avatar {
    width: 48px;
    height: 48px;
    background: #000080;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    box-shadow: var(--bevel-in);
}

.profile-card-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.profile-card-name {
    font-weight: bold;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-username {
    color: var(--text-secondary);
    font-size: 10px;
}

.profile-card-status {
    margin-top: 2px;
    font-size: 10px;
}

.profile-card-away {
    color: #996600;
    font-style: italic;
    font-size: 10px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-listening {
    color: #660099;
    font-style: italic;
    font-size: 10px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-custom-status {
    color: #336699;
    font-style: italic;
    font-size: 10px;
    margin-top: 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.profile-card-bio {
    color: #555555;
    font-size: 10px;
    margin-top: 4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.profile-card-joined {
    color: var(--text-secondary);
    font-size: 9px;
    margin-top: 4px;
}

/* === Push Prompt === */

.push-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    font-size: 11px;
    margin: 2px;
}

.push-prompt-text {
    flex: 1;
}

.push-prompt .retro-btn {
    min-width: 60px;
}

/* === Install Prompt === */

.install-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    font-size: 11px;
    margin: 2px;
}

.install-prompt-text {
    flex: 1;
}

.install-prompt .retro-btn {
    min-width: 60px;
}

/* === Voice Chat === */

.voice-participants {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 3px 6px;
    background: var(--bg-field);
    border-bottom: 1px solid var(--border-dark);
    font-size: 10px;
    min-height: 20px;
    align-items: center;
}

.voice-participant {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 5px;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    font-size: 10px;
    white-space: nowrap;
}

.voice-participant.speaking {
    box-shadow: 0 0 0 2px #00cc00, var(--bevel-out);
    animation: voice-speaking 0.6s ease-in-out infinite alternate;
}

@keyframes voice-speaking {
    0% { box-shadow: 0 0 0 1px #00cc00, var(--bevel-out); }
    100% { box-shadow: 0 0 0 2px #00cc00, var(--bevel-out); }
}

.voice-muted-icon {
    font-size: 10px;
    opacity: 0.6;
}

.voice-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    background: var(--bg-field);
    border-top: 1px solid var(--border-dark);
    border-bottom: 1px solid var(--border-dark);
    font-size: 10px;
    min-height: 22px;
}

.voice-bar-info {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-bar-controls {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.voice-bar-btn {
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 22px;
    height: 20px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.voice-bar-btn:active {
    box-shadow: var(--bevel-in);
}

.voice-bar-btn.active {
    box-shadow: var(--bevel-in);
    background: var(--border-light);
}

.voice-bar-disconnect {
    color: #cc0000;
    font-weight: bold;
}

/* === Ticker === */

.ticker-display {
    flex: 1;
    background: var(--bg-field);
    box-shadow: var(--bevel-in);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 10px;
    overflow: hidden;
    white-space: nowrap;
    padding: 2px 4px;
    min-height: 16px;
}

.ticker-text {
    display: inline-block;
    white-space: nowrap;
}

@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(var(--ticker-scroll-dist, -50%)); }
}

.ticker-item {
    font-weight: bold;
}

.ticker-item-stock.up {
    color: #006600;
}

.ticker-item-stock.down {
    color: #aa0000;
}

.ticker-item-weather {
    color: #004499;
}

.ticker-item-news {
    color: var(--text-primary);
}

.ticker-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.ticker-link:hover {
    text-decoration: underline;
}

.ticker-paused .ticker-link {
    text-decoration: underline;
}

.ticker-separator {
    color: var(--border-dark);
    margin: 0 6px;
}

.ticker-gear {
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.ticker-gear:active {
    box-shadow: var(--bevel-in);
}

.ticker-settings {
    position: fixed;
    z-index: 300;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    padding: 8px;
    width: 240px;
    font-size: 11px;
}

.ticker-settings-title {
    font-weight: bold;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-dark);
}

.ticker-settings-group {
    margin-bottom: 4px;
}

.ticker-settings-group label {
    display: block;
    margin-bottom: 2px;
    font-size: 10px;
}

.ticker-settings-group .retro-input {
    width: 100%;
    font-size: 10px;
    padding: 2px 4px;
    box-sizing: border-box;
}

.ticker-settings-buttons {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 6px;
}

/* === Mobile Message Layout === */

@media (max-width: 768px) {
    .message {
        display: block;
    }

    .message-timestamp,
    .message-author,
    .message-content {
        display: inline;
    }

    .message-image {
        max-width: 100%;
    }

    .link-preview {
        margin-left: 0;
        max-width: 100%;
    }

    .link-preview-image {
        width: 48px;
        height: 48px;
    }
}
