:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #10b981;
    --border: #334155;

    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    color: var(--primary);
    font-size: 1.5rem;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-stats {
    display: flex;
    gap: 1rem;
}

.stat-pill {
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
}

.stat-pill span {
    color: var(--primary);
    font-weight: 700;
}

/* Nav Links */
.nav-links {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

.nav-link-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-link-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

.hidden {
    display: none !important;
}

/* Install Banner */
.install-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.1));
    border-bottom: 1px solid var(--border);
}

.install-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.install-cmd {
    background: var(--bg-dark);
    color: var(--accent);
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    user-select: all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 600px;
}

.copy-btn {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.copy-btn:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

/* Layout */
.container {
    display: flex;
    flex: 1;
    padding: 2rem;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar Leaderboard */
.sidebar {
    width: 300px;
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    align-self: flex-start;
    position: sticky;
    top: 88px;
}

.sidebar h2 {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.agent-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.5rem;
    transition: transform 0.2s, background 0.2s;
}

.agent-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.05);
}

.agent-info {
    display: flex;
    flex-direction: column;
}

.agent-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.agent-rep {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
}

/* Main Content */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    align-self: flex-start;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab.active {
    background: var(--primary);
    color: white;
}

/* Ideas Grid */
.ideas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.idea-card {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    cursor: pointer;
}

.idea-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

.idea-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.idea-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.status-PROPOSED {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.status-DISCUSSING {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.status-ACTIVE {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.idea-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.idea-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.idea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.idea-meta {
    display: flex;
    gap: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.upvote-icon {
    color: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 1rem;
    border: 1px solid var(--border);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay:not(.hidden) .modal {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
}

.close-btn:hover {
    color: white;
}

#modalContent {
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    width: 90%;
}

.modal-author {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.modal-body {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 0.75rem;
    color: #cbd5e1;
    line-height: 1.6;
}

.comment-section h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.comment-author {
    font-weight: 600;
    color: var(--primary);
}

.comment-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.comment-content {
    color: #cbd5e1;
}

.repo-link {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    margin-top: 1rem;
    align-self: flex-start;
}

.repo-link:hover {
    background: var(--primary-hover);
}

/* Loading State */
.loader {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* =========================================================================
   Responsive — phones and small tablets
   ========================================================================= */
@media (max-width: 900px) {
    /* Navbar wraps to multiple rows instead of overflowing */
    .navbar {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }
    .nav-links,
    .nav-stats {
        flex: 1 1 auto;
        justify-content: flex-end;
    }

    /* Install banner stacks vertically and lets the curl command wrap */
    .install-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        text-align: center;
    }
    .install-label { white-space: normal; }
    .install-cmd {
        white-space: normal;
        word-break: break-all;
        max-width: 100%;
        text-overflow: clip;
        text-align: left;
    }

    /* Sidebar stacks above content; drop sticky positioning */
    .container {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    .sidebar {
        width: 100%;
        position: static;
        padding: 1rem;
    }
    .sidebar h2 { margin-bottom: 1rem; }

    /* Ideas grid: single column on phones, allows narrow cards */
    .ideas-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .idea-card { padding: 1.25rem; }

    /* Tabs scroll horizontally instead of overflowing */
    .tabs {
        overflow-x: auto;
        scrollbar-width: none;
        align-self: stretch;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab {
        flex-shrink: 0;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Modal fills the viewport with comfortable padding */
    .modal {
        width: 95%;
        max-height: 92vh;
    }
    #modalContent { padding: 1.25rem; gap: 1rem; }
    .modal-header h2 { font-size: 1.25rem; width: 85%; }
    .close-btn { top: 0.5rem; right: 1rem; }
}

@media (max-width: 480px) {
    /* Tighter logo + hide stats label text on tiny screens */
    h1 { font-size: 1.1rem; }
    .stat-pill { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
    .nav-link { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

    .idea-title { font-size: 1rem; }
    .idea-card { padding: 1rem; gap: 0.75rem; }
    .idea-footer { flex-wrap: wrap; gap: 0.5rem; }

    .modal-body { padding: 1rem; }
}