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

:root {
    --pinterest-red: #F96EA4;
    --pinterest-dark: #111111;
    --pinterest-gray: #767676;
    --pinterest-light-gray: #EFEFEF;
    --pinterest-white: #FFFFFF;
    --border-radius: 16px;
    --border-radius-large: 24px;
    --gap: 8px;
    --gap-small: 4px;
    --header-height: 64px;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: var(--pinterest-white);
    color: var(--pinterest-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--pinterest-white);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.header.hidden-header {
    transform: translateY(-100%);
}

.header.scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.header-container {
    max-width: 1680px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--pinterest-red);
    cursor: pointer;
}

.header-order-btn {
    text-decoration: none;
    color: var(--pinterest-dark);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border: 1.5px solid var(--pinterest-dark);
    border-radius: 24px;
    transition: all 0.3s ease;
    background: transparent;
}

.header-order-btn:hover {
    background-color: var(--pinterest-dark);
    color: var(--pinterest-white);
    transform: translateY(-1px);
}

.main {
    margin-top: var(--header-height);
    padding: 0 8px 16px;
    min-height: calc(100vh - var(--header-height));
}

/* Категории */
.categories-container {
    background: var(--pinterest-white);
    border-bottom: none;
    position: sticky;
    top: var(--header-height);
    z-index: 100;
    margin: 0 -8px;
    transition: top 0.3s ease;
}

.categories-container.no-header {
    top: 0;
}

.categories-wrapper {
    max-width: 2048px;
    margin: 0 auto;
    overflow: hidden;
    padding: 0 16px;
}

.categories-scroll {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    align-items: center;
    height: 48px;
}

.categories-scroll::-webkit-scrollbar {
    display: none;
}

.category-btn {
    background: none;
    border: none;
    padding: 0 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--pinterest-dark);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    letter-spacing: -0.2px;
}

.category-btn:hover {
    color: #111;
}

.category-btn.active {
    color: var(--pinterest-dark);
}

.category-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 100%;
    height: 3px;
    background-color: var(--pinterest-dark);
    transition: transform 0.2s ease;
    border-radius: 3px 3px 0 0;
}

.category-btn.active::after {
    transform: translateX(-50%) scaleX(1);
}

.category-btn:hover::after {
    transform: translateX(-50%) scaleX(1);
    background-color: #E0E0E0;
}

.category-btn.active:hover::after {
    background-color: var(--pinterest-dark);
}

.category-icon {
    display: none; /* Скрываем иконки для минималистичного вида */
}

.category-name {
    font-size: 14px;
}

.masonry-grid {
    position: relative;
    margin: 0 auto;
    max-width: 2048px;
    margin-top: 16px;
}

.grid-sizer {
    position: absolute;
    visibility: hidden;
}

.pin {
    position: absolute;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.pin:hover {
    transform: translateY(-2px);
}

.pin-inner {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--pinterest-light-gray);
}

.pin-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--border-radius);
}

.pin-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, transparent 70%, rgba(0, 0, 0, 0.4) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: var(--border-radius);
}

.pin:hover .pin-overlay {
    opacity: 1;
}


.pin-info {
    padding: 6px 0 4px 0;
}

.pin-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--pinterest-dark);
    margin-bottom: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.pin-description {
    font-size: 11px;
    color: var(--pinterest-gray);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.loading {
    text-align: center;
    padding: 12px 20px;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
}

.loading.hidden {
    display: none;
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--pinterest-light-gray);
    border-top-color: var(--pinterest-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Индикатор для свайпа */
.modal-content::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #d0d0d0;
    border-radius: 2px;
    z-index: 10;
    display: block;
}

.pin-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0);
    transition: background 0.4s ease;
    display: flex;
    align-items: flex-end;
}

.pin-modal.visible {
    background: rgba(0, 0, 0, 0.85);
}

.pin-modal.visible .modal-content {
    transform: translateY(0) !important;
}

/* Скроллбар для модального окна */
.modal-info::-webkit-scrollbar {
    width: 6px;
}

.modal-info::-webkit-scrollbar-track {
    background: transparent;
}

.modal-info::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.modal-info::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.modal-overlay {
    display: none;
}

.modal-content {
    position: relative;
    background: white;
    min-height: 90vh;
    width: 100%;
    max-width: 100%;
    margin: 0;
    margin-top: auto;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    overflow: hidden;
}

.modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2002;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.modal-close:hover {
    background: var(--pinterest-light-gray);
}

.modal-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    object-position: top;
    background: #f5f5f5;
    border-radius: 24px 24px 0 0;
    min-height: 300px;
    max-height: 60vh;
    transition: opacity 0.3s ease;
}

.modal-info {
    padding: 30px;
    background: white;
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 60px;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--pinterest-dark);
    line-height: 1.3;
}

.modal-description {
    font-size: 15px;
    color: var(--pinterest-gray);
    line-height: 1.6;
    margin-bottom: 8px;
}

.price-warning {
    background: #FFF3E0;
    border: 1px solid #FFB74D;
    border-radius: 12px;
    padding: 12px 16px;
    margin: 16px 0 20px 0;
    color: #E65100;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    word-wrap: break-word;
}

.modal-order-wrapper {
    position: relative;
}

.modal-buttons-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.modal-order-btn,
.modal-share-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.modal-order-btn {
    background: var(--pinterest-red);
    color: white;
}

.modal-order-btn:hover {
    background: #e85d90;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 110, 164, 0.3);
}

.modal-share-btn {
    background: #4a90e2;
    color: white;
}

.modal-share-btn:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}


.modal-checklist {
    background: var(--pinterest-light-gray);
    border-radius: 12px;
    padding: 16px;
    margin: 0 0 20px 0;
}

.modal-checklist-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--pinterest-dark);
}

.modal-checklist-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--pinterest-dark);
}

.modal-checklist-item:before {
    content: '✓';
    display: inline-block;
    width: 20px;
    height: 20px;
    background: var(--pinterest-red);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    margin-right: 10px;
    flex-shrink: 0;
    font-size: 12px;
}

.modal-order-wrapper {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    position: relative;
}

/* Десктоп */
@media (min-width: 769px) {
    .pin-modal {
        align-items: flex-start;
        padding: 20px;
        overflow-y: auto;
    }
    
    .modal-content {
        max-width: 900px;
        min-height: auto;
        margin: 20px auto;
        border-radius: 24px;
    }
    
    .modal-image {
        border-radius: 24px 24px 0 0;
        max-width: 100%;
    }
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .modal-content {
        min-height: 85vh;
        max-height: 95vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-info {
        padding: 20px;
    }
    
    .modal-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.5);
        color: white;
    }
    
    .modal-close:hover {
        background: rgba(0, 0, 0, 0.7);
    }
    
    .modal-buttons-row {
        flex-direction: column;
    }
    
    .modal-order-btn,
    .modal-share-btn {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .header {
        height: 56px;
    }
    
    .main {
        margin-top: 56px;
        padding: 0 4px 12px;
    }
    
    .categories-container {
        top: 56px;
    }
    
    .categories-container.no-header {
        top: 0;
    }
    
    .categories-wrapper {
        padding: 0 12px;
    }
    
    .categories-scroll {
        gap: 20px;
        height: 44px;
    }
    
    .category-btn {
        font-size: 14px;
        padding: 0 2px;
    }
    
    .category-name {
        font-size: 14px;
    }
    
    .category-btn::after {
        height: 2px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .header-order-btn {
        font-size: 13px;
        padding: 8px 16px;
    }
    
    .pin-title {
        font-size: 13px;
    }
    
    .pin-description {
        font-size: 11px;
    }
    
    .modal-content {
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .pin-info {
        padding: 6px 0;
    }
    
    .pin-save-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}