body {
    font-family: DejaVu Sans Mono, monospace;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #121212;
    color: #e0e0e0;
}

header {
    background-color: #000;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
}

nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

nav li {
    margin-left: 1.5rem;
}

nav a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

nav a:hover {
    color: #999;
}

/* ── Load More ─────────────────────────────────────────────── */
.load-more-container {
    padding: 0.5rem 1rem;
    background-color: #1e1e1e;
    border-bottom: 1px solid #333;
}

.load-more-btn {
    padding: 0.3rem 0.8rem;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.load-more-btn:hover { background-color: #555; }
.load-more-btn:disabled { background-color: #222; cursor: not-allowed; }

/* ── Layout ─────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    padding: 0;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.user-list {
    width: 200px;
    min-width: 200px;
    background-color: #1a1a1a;
    padding: 1rem;
    box-sizing: border-box;
    overflow-y: auto;
}

.user-list h3 { margin-top: 0; margin-bottom: 0.5rem; }

.online-users {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    background-color: #1e1e1e;
    padding: 0.75rem;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
}

.chat-header h2 { margin: 0; font-size: 1.1rem; margin-right: 1rem; }
.chat-header p  { margin: 0; font-size: 0.9rem; }

/* ── Messages ───────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    background-color: #1a1a1a;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 1rem;
}
.chat-messages::-webkit-scrollbar { display: none; }

.message {
    position: relative;
    margin-bottom: 0.1rem;
    padding: 0.1rem 2.5rem 0.1rem 0;
    max-width: 100%;
    word-wrap: break-word;
    display: flex;
    align-items: flex-start;
}

.message:not(.continued-message) {
    margin-top: 0.35rem;
}

.username-area {
    width: 11ch;
    min-width: 11ch;
    text-align: right;
    font-size: 0.8rem;
    flex-shrink: 0;
    padding-top: 0.15rem;
}

/* Hide the username column for continuation messages */
.continued-message .username-area {
    visibility: hidden;
}

.message-sender    { font-weight: bold; }
.message-separator { margin: 0; white-space: pre; }

.continued-message { margin-top: 0.05rem; }

/* timestamps removed */

.system-message {
    text-align: center;
    margin: 0.5rem 0;
    font-style: italic;
    color: #999;
}

/* ── Reply Button — REMOVED (click message/name to reply) ─────── */

/* ── Reply Thread: Reddit/GitHub comment style ───────────────────
   The .reply-thread lives INSIDE .message-content (right column).
   Its border-left IS the vertical bar. Everything is indented by
   padding-left, which puts it cleanly to the right of the username
   column — coming off the end of the message row, not the name.

   Row with a reply:
     ave  ~  │ ave: original text...    ← .reply-ref (faded quote line)
             │ perfect                  ← .reply-body (actual reply text)
──────────────────────────────────────────────────────────────── */
.reply-thread {
    border-left: 2px solid var(--thread-color, #555);
    padding-left: 8px;
    margin-top: 0;
    margin-left: 1px;
}

/* Faded quoted line: smaller, dimmer, truncated */
.reply-ref {
    font-size: 0.72em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
    margin-bottom: 1px;
    display: block;
    opacity: 0.5;
}
.reply-ref-author {
    font-weight: bold;
}
.reply-ref-text {
    /* inherits color from .reply-ref opacity */
}

/* The actual reply content */
.reply-body {
    padding-bottom: 0;
}

/* Message content right column */
.message-content {
    display: block;
    word-break: break-word;
    white-space: normal;
    flex: 1;
    padding-left: 0.5rem;
    min-width: 0;
    border-radius: 3px;
}
.message-content:hover {
    background: rgba(255,255,255,0.03);
}

/* Sender name: underline on hover to hint it's clickable */
.message-sender:hover {
    text-decoration: underline;
    opacity: 0.85;
}

/* ── Reply Preview Bar (above the input) ─────────────────────── */
.reply-preview {
    display: none;           /* toggled to flex by JS */
    align-items: center;
    gap: 0.5rem;
    background-color: #181818;
    border-top: 1px solid #3a3a3a;
    padding: 0.4rem 1rem;
    font-size: 0.82rem;
    color: #aaa;
}

.reply-preview-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-label {
    color: #666;
    flex-shrink: 0;
}

.reply-cancel-btn {
    background: none;
    border: none;
    color: #777;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    font-family: DejaVu Sans Mono, monospace;
}

.reply-cancel-btn:hover { color: #fff; }

/* ── Chat Form ───────────────────────────────────────────────── */
.chat-form {
    display: flex;
    padding: 1rem 1rem 1.2rem;
    background-color: #1e1e1e;
    border-top: 2px solid #2a2a2a;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.7rem;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 1rem;
    background-color: #2a2a2a;
    color: #e0e0e0;
}

.chat-button {
    margin-left: 0.5rem;
    padding: 0.7rem 1.5rem;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.chat-button:hover { background-color: #555; }

/* ── User List ───────────────────────────────────────────────── */
.user-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.user-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #4CAF50;
    margin-right: 0.5rem;
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.7);
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background-color: #1a1a1a;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    border: 1px solid #333;
}

.modal-content h2 { margin-top: 0; color: #e0e0e0; }

.form-group  { margin-bottom: 1rem; }

.form-input {
    width: 100%;
    padding: 0.7rem;
    margin-top: 0.3rem;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
    background-color: #2a2a2a;
    color: #e0e0e0;
}

.form-button {
    width: 100%;
    padding: 0.7rem;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.form-button:hover { background-color: #555; }

.error-message { color: #ff6b6b; margin-top: 0.5rem; font-size: 0.9rem; }

/* ── Loading ─────────────────────────────────────────────────── */
.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}
.loading-indicator::after { content: "Loading messages..."; color: #999; }

/* ── DND ─────────────────────────────────────────────────────── */
.dnd-toggle-container {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

/* ── Image Upload ────────────────────────────────────────────── */
.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #333;
    border-radius: 4px;
    margin-left: 0.5rem;
    cursor: pointer;
    transition: background-color 0.3s;
}
.upload-btn:hover { background-color: #555; }
.upload-icon      { font-size: 1.2rem; }

.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 4px;
    margin-top: 10px;
    cursor: pointer;
    display: block;
}

.image-loader {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top: 2px solid #3498db;
    animation: spin 1s linear infinite;
    margin-left: 5px;
}

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

/* ── Settings button ─────────────────────────────────────────── */
.settings-button {
    position: fixed;
    bottom: 20px; left: 20px;
    background-color: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-family: DejaVu Sans Mono, monospace;
    z-index: 100;
    transition: background-color 0.3s;
}
.settings-button:hover { background-color: #333; }

/* ──────────────────────────────────────────────────────────────
   CLIPS PAGE
   ────────────────────────────────────────────────────────────── */

/* Page wrapper for clips (overrides body height:100vh so page can scroll) */
body.clips-page {
    height: auto;
    min-height: 100vh;
}

.clips-main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* ── Upload area ─────────────────────────────────────────────── */
.clips-upload-section {
    background-color: #1a1a1a;
    border: 2px dashed #333;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: border-color 0.2s;
}

.clips-upload-section.dragover {
    border-color: #666;
    background-color: #1f1f1f;
}

.clips-upload-section h2  { margin-top: 0; }
.clips-upload-section p   { color: #777; font-size: 0.85rem; margin: 0.5rem 0 1rem; }

.clip-file-input  { display: none; }

.clip-upload-label {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    background-color: #333;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.2s;
    margin-right: 0.5rem;
}
.clip-upload-label:hover { background-color: #555; }

.clip-submit-btn {
    padding: 0.6rem 1.4rem;
    background-color: #2e5e2e;
    color: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: DejaVu Sans Mono, monospace;
    transition: background-color 0.2s;
}
.clip-submit-btn:hover    { background-color: #3d7a3d; }
.clip-submit-btn:disabled { background-color: #222; cursor: not-allowed; color: #666; }

.clip-selected-name {
    display: block;
    margin-top: 0.8rem;
    font-size: 0.8rem;
    color: #888;
}

.clip-upload-progress {
    display: none;
    margin-top: 1rem;
}

.clip-progress-bar-wrap {
    width: 100%;
    height: 6px;
    background-color: #2a2a2a;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.4rem;
}

.clip-progress-bar {
    height: 100%;
    width: 0%;
    background-color: #4CAF50;
    transition: width 0.3s;
}

/* ── Theater Mode Player ─────────────────────────────────────── */
.clips-theater {
    width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2a2a2a;
    margin-bottom: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.theater-video {
    width: 100%;
    max-height: 55vh;
    display: block;
    background: #000;
    object-fit: contain;
    cursor: pointer; /* click to pause/play */
}

.theater-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #0a0a0a;
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    border-top: 1px solid #1a1a1a;
}

.tc-btn {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #aaa;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    font-family: DejaVu Sans Mono, monospace;
    flex-shrink: 0;
}
.tc-btn:hover  { background: #2a2a2a; color: #fff; }
.tc-btn.active { background: #2e5e2e; border-color: #4a8a4a; color: #9fd49f; }

/* ── Trim control ──────────────────────────── */
.tc-trim-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}
.tc-trim-label {
    font-size: 0.65rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.tc-trim {
    width: 80px;
    accent-color: #5a5aff;
    cursor: pointer;
}
.tc-trim-val {
    font-size: 0.68rem;
    color: #8888cc;
    min-width: 2.8ch;
    font-family: DejaVu Sans Mono, monospace;
}
.tc-divider {
    width: 1px;
    height: 18px;
    background: #2a2a2a;
    margin: 0 0.2rem;
    flex-shrink: 0;
}

.tc-seek {
    flex: 1;
    min-width: 60px;
    accent-color: #7c6af7;
    cursor: pointer;
}

.tc-vol {
    width: 60px;
    accent-color: #7c6af7;
    cursor: pointer;
}

.tc-time {
    font-size: 0.72rem;
    color: #666;
    white-space: nowrap;
    font-family: DejaVu Sans Mono, monospace;
}

.tc-title {
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
    margin-left: auto;
}

/* ── Clips tab bar ───────────────────────────────────────────── */
.clips-tab-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-bottom: 1px solid #2a2a2a;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.clips-tab {
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    font-family: DejaVu Sans Mono, monospace;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    color: #666;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.clips-tab:hover  { color: #aaa; }
.clips-tab.active { color: #e0e0e0; border-bottom-color: currentColor; }
.clips-tab-users  { display: flex; gap: 0.4rem; flex-wrap: wrap; }
/* User tabs: active border uses the tab's own text color (set by JS) */
.clips-tab-users .clips-tab.active { border-bottom-color: currentColor; }

/* ── Player bar ──────────────────────────────────────────────── */
.clips-player-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    margin-bottom: 1rem;
}
.cpb-btn {
    background: #1e1e1e;
    border: 1px solid #333;
    color: #aaa;
    border-radius: 4px;
    padding: 0.25rem 0.55rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    font-family: DejaVu Sans Mono, monospace;
}
.cpb-btn:hover { background: #2a2a2a; color: #fff; }
.cpb-btn.active { background: #2e5e2e; border-color: #4a8a4a; color: #9fd49f; }
.cpb-label {
    font-size: 0.72rem;
    color: #555;
    margin-left: auto;
}

/* ── Clips grid ──────────────────────────────────────────────── */
.clips-grid-section {}

/* Month section */
.clips-month-section {
    margin-bottom: 2rem;
}
.clips-month-heading {
    font-size: 0.82rem;
    color: #666;
    text-transform: lowercase;
    letter-spacing: 0.06em;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #222;
}

/* 3-column grid, infinite rows */
.clips-month-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Older user-section rows (per-person tab) */
.clips-user-section {}
.clips-user-heading {
    font-size: 0.82rem;
    color: #666;
    text-transform: lowercase;
    letter-spacing: 0.06em;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #222;
}
.clips-user-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.clip-card {
    background-color: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.1s;
    cursor: pointer;
}
.clip-card:hover { border-color: #555; transform: translateY(-2px); }

/* Thumbnail container with play overlay */
.clip-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    overflow: hidden;
}
.clip-thumb video {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    pointer-events: none;
}
.clip-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.15s;
    cursor: pointer;
}
.clip-thumb:hover .clip-play-overlay { opacity: 1; }

.clip-card-info { padding: 0.5rem 0.7rem 0.6rem; }

.clip-card-name {
    font-size: 0.72rem; color: #aaa;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin: 0;
}
.clip-card-uploader {
    font-size: 0.7rem;
    /* color set dynamically per-user by JS */
    margin: 0.15rem 0 0;
    font-weight: bold;
}
.clip-card-date {
    font-size: 0.68rem; color: #555;
    margin-top: 0.15rem;
}
.clip-delete-btn {
    display: inline-block; margin-top: 0.35rem;
    padding: 0.15rem 0.45rem; font-size: 0.68rem;
    font-family: DejaVu Sans Mono, monospace;
    background: transparent; border: 1px solid #5a1a1a;
    color: #cf6f6f; border-radius: 3px; cursor: pointer;
    transition: background 0.15s;
}
.clip-delete-btn:hover { background: #3a1111; }

.clips-empty {
    text-align: center; color: #555;
    padding: 3rem; font-size: 0.9rem;
}
.clips-status-msg {
    text-align: center; padding: 0.5rem; font-size: 0.85rem;
    border-radius: 4px; margin-bottom: 1rem; display: none;
}
.clips-status-msg.success { background-color: #1b3a1b; color: #6fcf6f; display: block; }
.clips-status-msg.error   { background-color: #3a1b1b; color: #cf6f6f; display: block; }

/* ── Voice Panel ─────────────────────────────────────────────── */
.voice-panel {
    width: 160px;
    min-width: 160px;
    background-color: #111;
    border-left: 1px solid #222;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.voice-panel-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #555;
    margin: 0 0 0.5rem 0.25rem;
}

.voice-channel {
    border-radius: 4px;
    background: #1a1a1a;
    padding: 0.4rem 0.5rem;
}

.voice-channel-header {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.voice-channel-icon { font-size: 0.75rem; color: #555; }

.voice-channel-name {
    flex: 1;
    font-size: 0.78rem;
    color: #aaa;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-join-btn {
    padding: 0.15rem 0.45rem;
    font-size: 0.68rem;
    font-family: DejaVu Sans Mono, monospace;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.voice-join-btn:hover { background: #3a3a3a; color: #fff; }
.voice-join-btn.active { background: #2e5e2e; border-color: #4a8a4a; color: #9fd49f; }

.voice-members {
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.voice-member {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: #888;
    padding: 0.1rem 0.2rem;
}

.voice-member-icon { font-size: 0.65rem; }
.voice-member.muted .voice-member-icon::after { content: '🔇'; }

.voice-controls {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid #222;
}

.voice-ctrl-btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
    font-family: DejaVu Sans Mono, monospace;
    background: #1e1e1e;
    border: 1px solid #333;
    color: #aaa;
    border-radius: 3px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.voice-ctrl-btn:hover { background: #2a2a2a; color: #fff; }
.voice-ctrl-btn.active { background: #3a1a1a; border-color: #7a3a3a; color: #cf8f8f; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .main-content { flex-direction: column; }

    .user-list {
        width: 100%;
        min-height: auto;
        max-height: 100px;
        overflow-y: auto;
    }

    .online-users {
        max-height: 70px;
        display: flex;
        flex-wrap: wrap;
    }

    .clips-grid { grid-template-columns: 1fr; }
    .clips-main { padding: 1rem; }
}
