* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 20px;
}

.gallery-header {
    width: 100%;
    max-width: 1400px;
    margin-bottom: 24px;
    text-align: center;
}

h1 {
    color: #fff;
    font-size: 24px;
    letter-spacing: 0.02em;
}

input[type="text"],
input[type="url"],
input[type="date"],
textarea {
    width: 100%;
    padding: 10px 12px;
    background: #16213e;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus {
    border-color: #5c6bc0;
}

input::placeholder,
textarea::placeholder {
    color: #666;
    opacity: 1;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #4fc3f7;
    outline-offset: 2px;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}


/* Gallery */
.gallery-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}
.gallery-filters {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(135deg, rgba(22, 33, 62, 0.7), rgba(26, 26, 46, 0.9));
    border: 1px solid rgba(92, 107, 192, 0.15);
    border-radius: 12px;
    padding: 16px 18px;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}
.gallery-filter-row {
    display: flex;
    gap: 10px;
}
.gallery-filter-row input[type="text"] {
    background: rgba(15, 23, 41, 0.6);
    border: 1px solid rgba(92, 107, 192, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.gallery-filter-row input[type="text"]:focus {
    border-color: #5c6bc0;
    box-shadow: 0 0 0 3px rgba(92, 107, 192, 0.15);
}
.gallery-filter-row select {
    flex: 1;
    padding: 10px 14px;
    background: rgba(15, 23, 41, 0.6);
    border: 1px solid rgba(92, 107, 192, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.gallery-filter-row select:focus {
    border-color: #5c6bc0;
    box-shadow: 0 0 0 3px rgba(92, 107, 192, 0.15);
}
.gallery-filter-row select:hover {
    border-color: rgba(92, 107, 192, 0.4);
}
.gallery-tag-filter {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid rgba(92, 107, 192, 0.1);
    padding-top: 8px;
    margin-top: 2px;
}
.gallery-tag-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 6px 0;
    transition: opacity 0.15s;
}
.gallery-tag-header:hover {
    opacity: 0.85;
}
.gallery-tag-header-label {
    font-size: 12px;
    color: #7986cb;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.gallery-tag-header-label .arrow {
    font-size: 10px;
    transition: transform 0.2s;
    display: inline-block;
}
.gallery-tag-header-label .arrow.open {
    transform: rotate(90deg);
}
.gallery-tag-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.gallery-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    background: color-mix(in srgb, var(--tag-color, #5c6bc0) 25%, transparent);
    color: color-mix(in srgb, var(--tag-color, #5c6bc0) 60%, #fff);
    border: 1px solid color-mix(in srgb, var(--tag-color, #5c6bc0) 40%, transparent);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.gallery-tag-chip:hover {
    background: color-mix(in srgb, var(--tag-color, #5c6bc0) 35%, transparent);
    transform: scale(1.05);
}
.gallery-tag-chip .remove {
    font-size: 13px;
    line-height: 1;
    opacity: 0.7;
}
.gallery-tag-chip .remove:hover { opacity: 1; }
.gallery-tag-categories {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}
.gallery-tag-categories.open { display: flex; }
.gallery-tag-category-label {
    font-size: 10px;
    color: #7986cb;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-bottom: 2px;
}
.gallery-tag-category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.gallery-tag-pill {
    padding: 4px 12px;
    border: 1px solid color-mix(in srgb, var(--tag-color, #666) 40%, transparent);
    border-radius: 16px;
    background: rgba(15, 23, 41, 0.4);
    color: #bbb;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
}
.gallery-tag-pill:hover {
    background: color-mix(in srgb, var(--tag-color, #666) 18%, transparent);
    border-color: var(--tag-color, #666);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.gallery-tag-pill.active {
    background: var(--tag-color, #5c6bc0);
    border-color: var(--tag-color, #5c6bc0);
    color: #1a1a2e;
    font-weight: 600;
    box-shadow: 0 2px 12px color-mix(in srgb, var(--tag-color, #5c6bc0) 40%, transparent);
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.gallery-card {
    background: #16213e;
    border: 1px solid #333;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}
.gallery-card:hover {
    border-color: #5c6bc0;
    transform: translateY(-2px);
}
.gallery-card-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #0f1729;
}
.gallery-card-thumb-placeholder {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f1729;
    color: #444;
    font-size: 32px;
}
.gallery-card-info {
    padding: 10px 12px;
}
.gallery-card-desc {
    font-size: 13px;
    color: #ccc;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gallery-card-author {
    font-size: 12px;
    color: #8a9cc5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    margin-bottom: 4px;
}
.gallery-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.gallery-card-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(92,107,192,0.2);
    color: #9fa8da;
    cursor: pointer;
    transition: background 0.15s;
}
.gallery-card-tag:hover {
    background: rgba(92,107,192,0.35);
}
.gallery-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}
.gallery-empty {
    text-align: center;
    color: #555;
    padding: 60px 0;
    font-size: 16px;
}
.gallery-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}
.gallery-page-btn {
    padding: 6px 14px;
    background: #16213e;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.gallery-page-btn:hover { border-color: #5c6bc0; }
.gallery-page-btn:disabled { color: #444; cursor: not-allowed; border-color: #222; }
.gallery-page-info {
    padding: 6px 8px;
    color: #888;
    font-size: 13px;
    align-self: center;
}

/* Detail modal */
.detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
}
.detail-overlay.visible { display: flex; }
.detail-modal {
    background: #1a1a2e;
    width: 100%;
    max-width: min(700px, calc(100vw - 40px));
    border-radius: 12px;
    border: 1px solid #333;
    padding: 48px 24px 24px;
    position: relative;
}
.settings-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
}
.settings-close:hover {
    color: #fff;
    background: #333;
}
.detail-media {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    background: #0f1729;
    display: block;
    margin-bottom: 16px;
}
.detail-carousel {
    position: relative;
    margin-bottom: 16px;
}
.detail-carousel-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}
.detail-carousel-btn {
    background: #16213e;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    padding: 4px 12px;
    font-size: 16px;
    font-family: inherit;
}
.detail-carousel-btn:disabled { color: #444; cursor: not-allowed; }
.detail-carousel-index { color: #888; font-size: 13px; }
.detail-field { margin-bottom: 12px; }
.detail-field-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.detail-field-value { font-size: 14px; color: #e0e0e0; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-tag {
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(92,107,192,0.2);
    color: #9fa8da;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}
.detail-tag:hover {
    background: rgba(92,107,192,0.35);
}
.detail-authors { display: flex; flex-direction: column; gap: 4px; }
.detail-author a { color: #7986cb; text-decoration: none; }
.detail-author a:hover { text-decoration: underline; }

/* Author name (clickable filter) */
.author-name {
    cursor: pointer;
    color: #9fa8da;
    font-weight: 500;
}
.author-name:hover { text-decoration: underline; color: #c5cae9; }

/* Author links (platform badges) */
.author-links {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    flex-wrap: wrap;
}
.author-link-tag {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 4px;
    background: #1e2d40;
    color: #90caf9;
    text-decoration: none;
    border: 1px solid #263545;
    letter-spacing: 0.02em;
}
.author-link-tag:hover { background: #263d55; color: #fff; text-decoration: none; }
.author-link-tag.platform-telegram { border-color: #1565c0; color: #90caf9; }
.author-link-tag.platform-twitter { border-color: #37474f; color: #b0bec5; }
.author-link-tag.platform-vk { border-color: #1a237e; color: #9fa8da; }

/* Gallery card clickable author */
.gallery-card-author .author-link {
    cursor: pointer;
    color: #8a9cc5;
}
.gallery-card-author .author-link:hover {
    text-decoration: underline;
    color: #c5cae9;
}

/* Mobile filter toggle button */
.gallery-filter-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #16213e;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 8px;
    min-height: 44px;
    transition: border-color 0.2s;
}
.gallery-filter-toggle:hover { border-color: #5c6bc0; }

/* === Media queries === */

@media (min-width: 1201px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 20px;
    }
    .gallery-filters {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 18px 22px;
    }
    .gallery-filters .gallery-filter-row {
        flex: 1;
        min-width: 200px;
    }
    .gallery-filters .gallery-tag-filter {
        flex: 1 1 100%;
    }
}

@media (max-width: 1023px) {
    body {
        padding: 24px 16px;
    }
    .gallery-grid {
        gap: 12px;
    }
}

@media (max-width: 767px) {
    body {
        padding: 16px 12px;
    }
    h1 {
        font-size: 20px;
    }
    .gallery-filter-toggle {
        display: flex;
    }
    .gallery-filters {
        display: none;
        padding: 12px 14px;
        border-radius: 8px;
    }
    .gallery-filters.open {
        display: flex;
    }
    .gallery-filter-row {
        flex-direction: column;
    }
    .gallery-filter-row select,
    .gallery-filter-row input {
        min-height: 44px;
        font-size: 16px;
    }
    .gallery-tag-pill {
        padding: 6px 14px;
        min-height: 36px;
    }
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .detail-overlay {
        padding: 16px 8px;
    }
    .detail-modal {
        padding: 40px 16px 16px;
        border-radius: 8px;
    }
    .gallery-page-btn {
        padding: 10px 18px;
        min-height: 44px;
    }
}

@media (max-width: 400px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}
