* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 50px 20px 30px;
    text-align: center;
    border-bottom: 1px solid #2a2a4a;
}

header h1 {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

header p {
    font-size: 1.05rem;
    color: #8892b0;
    max-width: 600px;
    margin: 0 auto 24px;
}

/* Search Bar */
.search-wrapper {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

.search-wrapper input {
    width: 100%;
    padding: 12px 20px 12px 44px;
    border-radius: 8px;
    border: 1px solid #2a2a4a;
    background: #0f0f1a;
    color: #e0e0e0;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-wrapper input:focus {
    border-color: #6c63ff;
}

.search-wrapper input::placeholder {
    color: #5a5a7a;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #5a5a7a;
    pointer-events: none;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px 0;
    flex-wrap: wrap;
    gap: 16px;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 7px 18px;
    border: 1px solid #2a2a4a;
    background: transparent;
    color: #8892b0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    background: #6c63ff;
    border-color: #6c63ff;
    color: #fff;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sort-select {
    padding: 7px 14px;
    border: 1px solid #2a2a4a;
    background: #1a1a2e;
    color: #8892b0;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.sort-select:focus {
    border-color: #6c63ff;
}

.view-toggle {
    display: flex;
    gap: 4px;
}

.view-btn {
    padding: 7px 10px;
    border: 1px solid #2a2a4a;
    background: transparent;
    color: #8892b0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn:hover,
.view-btn.active {
    background: #6c63ff;
    border-color: #6c63ff;
    color: #fff;
}

.results-count {
    font-size: 0.85rem;
    color: #5a5a7a;
    padding: 10px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Container & Grid */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px 20px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 28px;
    transition: all 0.3s;
}

.grid.list-view {
    grid-template-columns: 1fr;
}

.grid.list-view .card {
    flex-direction: row;
}

.grid.list-view .card-image {
    width: 260px;
    height: auto;
    min-height: 180px;
}

.grid.list-view .card-body {
    padding: 20px 24px;
}

/* Cards */
.card {
    background: #1a1a2e;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #2a2a4a;
    transition: transform 0.3s, box-shadow 0.3s, opacity 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.card.hidden {
    display: none;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(108, 99, 255, 0.15);
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background: #16213e;
}

.card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-body h3 {
    font-size: 1.15rem;
    color: #fff;
    margin-bottom: 6px;
}

.card-meta {
    font-size: 0.78rem;
    color: #5a5a7a;
    margin-bottom: 10px;
}

.card-body p {
    font-size: 0.88rem;
    color: #8892b0;
    line-height: 1.6;
    margin-bottom: 16px;
    flex: 1;
}

.card-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tag {
    padding: 4px 10px;
    background: rgba(108, 99, 255, 0.15);
    color: #6c63ff;
    border-radius: 4px;
    font-size: 0.73rem;
    font-weight: 500;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-link {
    display: inline-block;
    padding: 9px 20px;
    background: #6c63ff;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.card-link:hover {
    background: #5a52d5;
}

.btn-preview {
    padding: 9px 16px;
    border: 1px solid #2a2a4a;
    background: transparent;
    color: #8892b0;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-preview:hover {
    border-color: #6c63ff;
    color: #6c63ff;
}

.btn-favorite {
    margin-left: auto;
    background: none;
    border: none;
    color: #5a5a7a;
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
    padding: 4px;
}

.btn-favorite:hover,
.btn-favorite.active {
    color: #ff6b6b;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 40px 20px;
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid #2a2a4a;
    background: transparent;
    color: #8892b0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    min-width: 38px;
    text-align: center;
}

.page-btn:hover,
.page-btn.active {
    background: #6c63ff;
    border-color: #6c63ff;
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn:disabled:hover {
    background: transparent;
    border-color: #2a2a4a;
    color: #8892b0;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: #1a1a2e;
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #2a2a4a;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #8892b0;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
}

.modal-body {
    padding: 30px;
}

.modal-body h2 {
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 8px;
}

.modal-body .modal-meta {
    font-size: 0.85rem;
    color: #5a5a7a;
    margin-bottom: 16px;
}

.modal-body .modal-desc {
    font-size: 0.95rem;
    color: #8892b0;
    line-height: 1.7;
    margin-bottom: 20px;
}

.modal-body .modal-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.modal-body .modal-actions {
    display: flex;
    gap: 12px;
}

.modal-body .modal-actions a,
.modal-body .modal-actions button {
    padding: 11px 24px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.modal-body .modal-actions .btn-primary {
    background: #6c63ff;
    color: #fff;
    border: none;
}

.modal-body .modal-actions .btn-primary:hover {
    background: #5a52d5;
}

.modal-body .modal-actions .btn-secondary {
    background: transparent;
    color: #8892b0;
    border: 1px solid #2a2a4a;
}

.modal-body .modal-actions .btn-secondary:hover {
    border-color: #6c63ff;
    color: #6c63ff;
}

/* Back to top */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #6c63ff;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.3);
    transition: transform 0.2s, opacity 0.2s;
    z-index: 100;
}

.back-to-top.visible {
    display: flex;
}

.back-to-top:hover {
    transform: scale(1.1);
}

/* No results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #5a5a7a;
    display: none;
}

.no-results.visible {
    display: block;
}

.no-results svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.2rem;
    color: #8892b0;
    margin-bottom: 8px;
}

/* Footer */
footer {
    text-align: center;
    padding: 40px 20px;
    color: #4a4a6a;
    font-size: 0.85rem;
    border-top: 1px solid #2a2a4a;
    margin-top: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .grid.list-view .card {
        flex-direction: column;
    }

    .grid.list-view .card-image {
        width: 100%;
        height: 200px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-right {
        justify-content: space-between;
    }

    .modal-image {
        height: 200px;
    }
}
