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

:root {
    --pixiv-blue: #0096fa;
    --pixiv-red: #ff4060;
    --background: #f5f5f5;
    --background-secondary: #ffffff;
    --surface: #ffffff;
    --text-primary: #333333;
    --text-secondary: #767676;
    --border: #e5e5e5;
    --hover-bg: #f8f8f8;
    --shadow: rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif, 'Segoe UI', Roboto;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header - Pixiv風 */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px var(--shadow);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pixiv-blue);
    letter-spacing: -0.5px;
}

.header-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Search Bar - Pixiv風 */
.search-bar {
    margin: 1.5rem 0 1rem;
}

#searchInput {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--pixiv-blue);
    box-shadow: 0 0 0 1px var(--pixiv-blue);
}

#searchInput::placeholder {
    color: var(--text-secondary);
}

/* Filter Bar - Pixivタブ風 */
.filter-bar {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.2s ease;
    position: relative;
    margin-bottom: -1px;
}

.filter-btn:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.filter-btn.active {
    color: var(--pixiv-blue);
    border-bottom-color: var(--pixiv-blue);
}

/* Loading & Error */
.loading, .error {
    text-align: center;
    padding: 3rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.error {
    color: var(--pixiv-red);
}

/* Gallery Grid - Pixiv風グリッド */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 3rem;
}

.gallery-item {
    position: relative;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px var(--shadow);
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
    padding: 0.875rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modal - Pixiv作品ページ風 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    border-radius: 8px;
    max-width: 1200px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 50%;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

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

.detail-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    padding: 2rem;
}

.detail-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: 4px;
    overflow: hidden;
}

.detail-image img {
    width: 100%;
    height: auto;
    display: block;
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.detail-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.detail-info p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
}

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

.tag {
    padding: 0.375rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.tag:hover {
    background: var(--hover-bg);
    border-color: var(--pixiv-blue);
}

.detail-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    background: var(--hover-bg);
}

.btn-like {
    border-color: var(--pixiv-red);
    color: var(--pixiv-red);
}

.btn-like:hover {
    background: rgba(255, 64, 96, 0.05);
}

.btn-like.active {
    background: var(--pixiv-red);
    border-color: var(--pixiv-red);
    color: white;
}

.btn-bookmark {
    border-color: var(--pixiv-blue);
    color: var(--pixiv-blue);
}

.btn-bookmark:hover {
    background: rgba(0, 150, 250, 0.05);
}

.btn-bookmark.active {
    background: var(--pixiv-blue);
    border-color: var(--pixiv-blue);
    color: white;
}

/* Responsive */
@media (max-width: 1024px) {
    .detail-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }

    .gallery-item img {
        height: 220px;
    }

    .detail-container {
        padding: 1.5rem;
    }

    .filter-btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .gallery-item img {
        height: 180px;
    }

    .logo {
        font-size: 1.25rem;
    }

    .header-info {
        font-size: 0.8125rem;
    }

    .detail-container {
        padding: 1rem;
    }

    .detail-info h2 {
        font-size: 1.25rem;
    }

    .detail-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* スクロールバーのカスタマイズ（Webkit系ブラウザ） */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}
