.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.modal.show {
    opacity: 1;
}

.modal-content-wrapper {
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    position: relative;
    gap: 20px;
}

.modal-image-area {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.modal-sidebar {
    width: 300px;
    background: rgba(30, 30, 30, 0.5);
    border-left: 1px solid #444;
    padding: 20px;
    display: flex;
    flex-direction: column;
    color: #e0e0e0;
    overflow-y: auto;
    border-radius: 4px;
}

.modal-sidebar h2 {
    margin-top: 0;
    font-size: 20px;
    margin-bottom: 10px;
    text-align: left;
    color: #ffffff;
}

.modal-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-sidebar .modal-date {
    color: #aaaaaa;
    font-size: 14px;
}

.modal-sidebar .heart-count {
    color: #aaaaaa;
    font-size: 12px;
}

.modal-sidebar .heart-icon {
    stroke: #e0e0e0;
}

.modal-sidebar .heart-container.liked .heart-icon {
    fill: #ff4081;
    stroke: #ff4081;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    margin-bottom: 20px;
}

.modal-tag-item {
    background-color: #333;
    color: #e0e0e0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-tag-item:hover {
    background-color: #555;
    color: #ffffff;
}

.related-images-section {
    margin-top: auto;
    border-top: 1px solid #444;
    padding-top: 15px;
}

.related-images-section h3 {
    font-size: 14px;
    margin-top: 0;
    margin-bottom: 10px;
    color: #aaaaaa;
}

.related-images-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.related-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    background-color: #000;
}

.related-img:hover {
    transform: scale(1.05);
    opacity: 0.8;
}

.modal-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 2px;
    transition: transform 0.1s linear;
    cursor: zoom-in;
    user-select: none;
    z-index: 10;
}

.modal-content.zoomed {
    max-width: none;
    max-height: none;
    cursor: grab;
    transition: none; 
}

.modal-content.zoomed:active {
    cursor: grabbing;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.2s;
    line-height: 1;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 50px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    z-index: 1001;
    padding: 20px;
    user-select: none;
    transition: color 0.2s, transform 0.2s;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.nav-btn:hover {
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.prev-btn { left: 20px; }
.next-btn { right: 20px; }

.legal-box {
    max-width: 600px;
    width: 90%;
}

.legal-content {
    text-align: left;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.6;
    margin-top: 20px;
}

.legal-content p {
    margin-bottom: 15px;
}

.legal-content ul {
    margin-bottom: 15px;
    padding-left: 20px;
}

.legal-content li {
    margin-bottom: 5px;
}

.legal-contact {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--drop-zone-border);
    text-align: center;
}

.contact-email {
    color: #007acc;
    font-weight: bold;
    text-decoration: none;
    font-size: 16px;
}

.contact-email:hover {
    text-decoration: underline;
}

@media (max-width: 800px) {
    .modal-content-wrapper {
        flex-direction: column;
    }
    .modal-sidebar {
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 1px solid #444;
    }
    .modal-image-area {
        flex: 3;
    }
    .related-images-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
