:root {
    --bg-main: #000000;
    --bg-card: #0a0a0a;
    --border: #333333;
    --text-main: #ffffff;
    --text-dim: #a3a3a3;
    --accent: #3b82f6;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 3rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.02em;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: relative;
    /* For floating badge positioning */
}

.copy-badge {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    pointer-events: none;
    animation: fade-up 0.8s ease-out forwards;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

@keyframes fade-up {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.8);
    }

    20% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1.1);
    }

    40% {
        transform: translateX(-50%) translateY(-2px) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.9);
    }
}

@keyframes btn-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.92);
    }

    100% {
        transform: scale(1);
    }
}

.btn-pop {
    animation: btn-pop 0.2s ease-out;
}

.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: normal;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    height: 32px;
    box-sizing: border-box;
}

.info-btn:hover {
    color: var(--text-main);
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--success);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.5;
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }

    70% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        transform: scale(0.95);
        opacity: 0.5;
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

#search-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 1rem;
    width: 320px;
    transition: border-color 0.2s;
}

#search-box:focus {
    outline: none;
    border-color: var(--accent);
}

.add-room-container {
    display: flex;
    gap: 0.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border);
}

#add-room-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1.25rem;
    border-radius: 8px 0 0 8px;
    font-size: 0.9rem;
    width: 240px;
    transition: border-color 0.2s;
}

#add-room-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0 1.25rem;
    border-radius: 0 8px 8px 0;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.2s;
}

#add-room-btn:hover {
    filter: brightness(1.1);
}

#add-room-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.2s, border-color 0.2s;
    height: 100%;
    box-sizing: border-box;
    min-width: 0;
    /* Prevent content overflow */
}

.card:hover {
    transform: translateY(-4px);
    border-color: #525252;
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    /* Ensure children can truncate */
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.room-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    flex-grow: 1;
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
}

.momentum-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}

.momentum-up {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.momentum-down {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.momentum-icon {
    font-size: 0.8rem;
}

.alias {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topic {
    font-size: 0.95rem;
    color: #888;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
    flex-grow: 1;
    min-height: 3.2em;
}

.card-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.footer-main-row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 1rem;
    width: 100%;
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 600;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.join-btn {
    margin-left: auto;
    background: transparent;
    color: var(--text-dim);
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    height: fit-content;
}

.join-btn:hover {
    color: var(--text-main);
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* ── Dropdown ── */
.dropdown {
    position: relative;
    margin-left: auto;
}

.dropdown-toggle {
    background: transparent;
    color: var(--text-dim);
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.dropdown-toggle:hover {
    color: var(--text-main);
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.dropdown-toggle::after {
    content: "▾";
    font-size: 0.7rem;
    opacity: 0.7;
}

.dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #111;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 140px;
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.dropdown.active .dropdown-menu {
    display: flex;
}

.dropdown-item {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.dropdown-item:hover {
    color: var(--text-main);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2rem 0 1.5rem 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-title::after {
    content: "";
    height: 1px;
    background: var(--border);
    flex-grow: 1;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 6rem;
    color: var(--text-dim);
    font-size: 1.2rem;
    border: 1px dashed var(--border);
    border-radius: 12px;
}

/* ── Activity Chart ── */
.chart-container {
    background: linear-gradient(135deg, #0a0a0a 0%, #050505 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1rem 3rem 1rem;
    margin-bottom: 3rem;
    position: relative;
    height: 400px;
    min-height: 0;
}

.chart-container canvas {
    width: 100% !important;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 1rem;
    text-align: center;
    padding: 2rem;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: #0d0d0d;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 560px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.02em;
}

.modal h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.modal p {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-dim);
    margin: 0;
}

.modal p strong {
    color: var(--text-main);
}

.modal-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal ul {
    margin: 0.75rem 0 0 0;
    padding-left: 1.25rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.8;
}

.modal ul code {
    background: rgba(255, 255, 255, 0.06);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent);
}

.modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* ── Stats Overview ── */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
    margin-top: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
}

@media (max-width: 900px) {
    .stats-overview {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Responsive ── */
@media (max-width: 900px) {
    body {
        padding: 1.5rem;
    }

    header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    #search-box {
        width: 100%;
        box-sizing: border-box;
    }

    .add-room-container {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--border);
        padding-top: 0.75rem;
    }

    #add-room-input {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .room-grid {
        grid-template-columns: 1fr;
    }


}

@media (max-width: 500px) {
    body {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.3rem;
    }

    .title-row {
        flex-wrap: wrap;
    }

    .card {
        padding: 1rem;
    }

    .footer-main-row {
        flex-wrap: nowrap;
        gap: 0.75rem;
    }

    .join-btn {
        margin-left: auto;
        width: auto;
        text-align: center;
    }

    .room-name {
        font-size: 1.05rem;
    }

    .alias {
        font-size: 0.75rem;
    }

    .stat-value {
        font-size: 0.8rem;
    }

    .empty-state {
        padding: 3rem 1rem;
    }
}
/* ── Server Tag ── */
.server-tag {
    font-size: 0.75rem;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    opacity: 0.9;
}

.server-icon {
    font-size: 0.8rem;
    opacity: 0.8;
}
