:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-hover: #334155;
    --card: #1e293b;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-bright: #ffffff;
    --border: #334155;
    --success: #10b981;
    
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

header {
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
}

.brand {
    display: flex;
    gap: 16px;
    align-items: center;
}

.brand .logo {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.brand-text h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-bright);
}

.brand a {
    text-decoration: none;
    display: flex;
}

.brand a:hover .logo {
    transform: scale(1.05);
    transition: var(--transition);
}

.brand-text p {
    margin: 4px 0 0 0;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}

.search {
    position: relative;
}

.search input {
    padding: 12px 16px 12px 42px;
    border-radius: var(--radius);
    width: 340px;
    outline: none;
    font-size: 14px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
}

.search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.search::before {
    content: "🔍";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-muted);
    z-index: 1;
}

.controls {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.controls .left {
    display: flex;
    gap: 20px;
    align-items: center;
}

.stats, .perpage-container {
    padding: 10px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

.stats b {
    font-weight: 600;
    color: var(--text);
}

.stats span {
    font-weight: 700;
    color: var(--accent);
}

.perpage-container label {
    font-size: 14px;
    font-weight: 500;
    margin-right: 8px;
    color: var(--text);
}

.perpage-container select {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.perpage-container select:focus {
    border-color: var(--accent);
}

.source-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
}

.source-link:hover {
    background: var(--accent-hover);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 12px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: start;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}

.card img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #1e293b, #334155);
    padding: 8px;
}

.card h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-bright);
}

.meta {
    font-size: 13px;
    width: 100%;
    color: var(--text);
}

.meta strong {
    font-weight: 500;
    color: var(--text-bright);
}

.pager {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 32px;
    justify-content: center;
}

.pager button {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    min-width: 44px;
}

.pager button:hover:not(.active) {
    background: var(--bg-hover);
}

.pager button.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.footer-note {
    font-size: 12px;
    margin-top: 8px;
    opacity: 0.7;
}

footer a {
    color: var(--accent);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    max-width: 800px;
    width: 100%;
    padding: 24px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
    box-shadow: var(--shadow-lg);
    animation: modalAppear 0.3s ease-out;
    border: 1px solid var(--border);
}

.modal-image img {
    width: 300px;
    height: 300px;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-shrink: 0;
    background: linear-gradient(135deg, #1e293b, #334155);
    padding: 12px;
}

.modal .info {
    flex: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-bright);
}

.close-btn {
    background: transparent;
    border: 0;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text);
}

.close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
}

.modal-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.modal-meta p {
    margin: 0;
    font-size: 15px;
    color: var(--text);
}

.modal-meta strong {
    color: var(--text-bright);
}

.modal-desc {
    margin-top: 16px;
    font-size: 15px;
    line-height: 1.6;
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent);
    background: var(--bg-secondary);
    color: var(--text);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
    color: var(--text);
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-bright);
}

@media (max-width: 768px) {
    .wrap {
        padding: 16px;
    }
    
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .search input {
        width: 100%;
    }
    
    .controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }
    
    .modal {
        flex-direction: column;
        align-items: center;
        padding: 20px;
    }
    
    .modal-image img {
        width: 100%;
        max-width: 400px;
        height: 250px;
    }
    
    .pager button {
        padding: 8px 12px;
        min-width: 40px;
    }
}

@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .brand {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .brand-text h1 {
        font-size: 20px;
    }
}