:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #22262f;
    --bg-card-hover: #2a2f3a;
    --bg-input: #181b23;
    --border: #2e3340;
    --border-focus: #4a9eff;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;
    --accent: #4a9eff;
    --green: #34d399;
    --yellow: #fbbf24;
    --orange: #f97316;
    --red: #ef4444;
    --purple: #a78bfa;
    --radius: 8px;
    --radius-sm: 4px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", "Fira Code", monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 0 24px 48px;
}

/* Header */
#header {
    text-align: center;
    padding: 32px 0 16px;
}

#header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

/* Stats Bar */
#stats-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    text-align: center;
    min-width: 120px;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font-mono);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Toolbar */
#toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

#toolbar input[type="text"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.875rem;
    font-family: var(--font);
    outline: none;
    flex: 1;
    min-width: 180px;
}

#toolbar input[type="text"]:focus {
    border-color: var(--border-focus);
}

#toolbar input[type="text"]::placeholder {
    color: var(--text-muted);
}

#toolbar select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.875rem;
    font-family: var(--font);
    outline: none;
    cursor: pointer;
    min-width: 140px;
}

#toolbar select:focus {
    border-color: var(--border-focus);
}

#toolbar button {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 14px;
    font-size: 0.8rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

#toolbar button:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* NFT Grid — compact, ~15 per row */
#nft-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 4px;
}

.nft-card {
    border: 1px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    position: relative;
}

.nft-card:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    z-index: 1;
}

.nft-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: var(--bg-secondary);
}

/* Hide info bar by default, show on hover */
.nft-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 4px;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: space-between;
}

.nft-card:hover .nft-card-info { display: flex; }

.nft-card-name {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge {
    font-size: 0.5rem;
    font-weight: 700;
    padding: 1px 3px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-one-of-one {
    background: rgba(251, 191, 36, 0.3);
    color: var(--yellow);
}

.badge-generative {
    background: rgba(74, 158, 255, 0.2);
    color: var(--accent);
}

/* 1/1 cards get a gold border */
.nft-card.one-of-one { border-color: rgba(251, 191, 36, 0.3); }

.nft-card-traits { display: none; }

.trait-tag {
    font-size: 0.65rem;
    padding: 2px 5px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Load More */
#load-more-wrap {
    text-align: center;
    margin-top: 24px;
}

#load-more-wrap button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 10px 28px;
    font-size: 0.9rem;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

#load-more-wrap button:hover {
    opacity: 0.85;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 101;
    max-width: 700px;
    width: 92vw;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.hidden {
    display: none !important;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-image {
    width: 100%;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    background: var(--bg-primary);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-attrs {
    width: 100%;
    border-collapse: collapse;
}

.modal-attrs th,
.modal-attrs td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.modal-attrs th {
    color: var(--text-secondary);
    font-weight: 500;
    width: 35%;
}

.modal-attrs td {
    color: var(--text-primary);
    font-weight: 600;
}

/* Trait Distribution */
#trait-distribution {
    margin-top: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

#trait-distribution summary {
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
    user-select: none;
}

#trait-charts {
    margin-top: 16px;
}

.layer-chart {
    margin-bottom: 20px;
}

.layer-chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.bar-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 120px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-track {
    flex: 1;
    height: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.3s;
}

.bar-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 40px;
    font-family: var(--font-mono);
}

/* Rarity colors for bars */
.rarity-common { background: var(--accent); }
.rarity-uncommon { background: var(--green); }
.rarity-rare { background: var(--purple); }
.rarity-epic { background: var(--orange); }
.rarity-legendary { background: var(--yellow); }
.rarity-mythic { background: var(--red); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.empty-state pre {
    display: inline-block;
    text-align: left;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-top: 8px;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 0 12px 32px;
    }

    #toolbar {
        flex-direction: column;
    }

    #toolbar input[type="text"],
    #toolbar select {
        width: 100%;
    }

    #nft-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 3px;
    }

    .stat-card {
        min-width: 90px;
        padding: 8px 12px;
    }

    .stat-card .stat-value {
        font-size: 1.1rem;
    }

    .modal {
        width: 96vw;
        padding: 16px;
    }

    .bar-label {
        min-width: 80px;
        font-size: 0.65rem;
    }
}
