/* ═══════════════════════════════════════
   GALLERY PAGE (/gallery)
   ═══════════════════════════════════════ */

.gallery-page {
    max-width: 900px;
    margin: 0 auto;
}

.gallery-header {
    text-align: center;
    margin-bottom: 24px;
}

.gallery-header h2 {
    font-size: 1.4rem;
    margin: 0 0 6px;
}

.gallery-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* Search */

.gallery-search {
    margin-bottom: 16px;
}

.gallery-search input {
    width: 100%;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.gallery-search input:focus {
    border-color: var(--border-focus);
}

/* Category tabs */

.gallery-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.gallery-tabs::-webkit-scrollbar {
    display: none;
}

.gallery-tab {
    background: var(--accent-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    font-family: inherit;
}

.gallery-tab:hover {
    background: var(--accent-bg-strong);
    border-color: var(--border-hover);
}

.gallery-tab.active {
    background: var(--accent);
    color: var(--btn-text);
    border-color: var(--accent);
}

/* Characters grid */

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

.gallery-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.gallery-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}

.gallery-card-avatar {
    width: 100%;
    aspect-ratio: 1;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 700;
    font-size: 2.5rem;
    overflow: hidden;
}

.gallery-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-card-info {
    padding: 12px 14px;
}

.gallery-card-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-card-personality {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.gallery-card-category {
    display: inline-block;
    font-size: 0.65rem;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
    margin-top: 6px;
}

/* Empty state */

.gallery-empty {
    padding: 60px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ═══════════════════════════════════════
   DETAIL MODAL
   ═══════════════════════════════════════ */

.gallery-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.gallery-modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 92%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.gallery-modal-content .btn-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 2;
}

.gallery-modal-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 20px 16px;
}

.gallery-modal-avatar {
    width: 80px;
    height: 80px;
    border-radius: 14px;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 700;
    font-size: 2rem;
    flex-shrink: 0;
    overflow: hidden;
}

.gallery-modal-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-modal-title h2 {
    margin: 0;
    font-size: 1.2rem;
}

.gallery-modal-source {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.gallery-modal-body {
    padding: 0 20px 16px;
}

.gallery-detail {
    margin-bottom: 14px;
}

.gallery-detail h4 {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 4px;
    font-weight: 600;
}

.gallery-detail p {
    font-size: 0.88rem;
    color: var(--text);
    margin: 0;
    line-height: 1.5;
    white-space: pre-wrap;
}

.gallery-modal-actions {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.gallery-modal-actions .btn-secondary,
.gallery-modal-actions .btn-primary {
    flex: 1;
    text-align: center;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
}

.gallery-modal-actions .btn-secondary {
    background: var(--accent-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.gallery-modal-actions .btn-secondary:hover {
    background: var(--accent-bg-strong);
}

.gallery-modal-actions .btn-primary {
    background: var(--accent);
    color: var(--btn-text);
    border: none;
}

.gallery-modal-actions .btn-primary:hover {
    background: var(--accent-hover);
}

.gallery-modal-actions .btn-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
}

.gallery-modal-actions .btn-link:hover {
    color: var(--accent);
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

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

    .gallery-card-avatar {
        font-size: 2rem;
    }

    .gallery-card-personality {
        display: none;
    }

    .gallery-modal-content {
        width: 96%;
        max-height: 90vh;
    }

    .gallery-modal-actions {
        flex-direction: column;
    }
}
