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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #fafaf8;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    margin-bottom: 60px;
    text-align: center;
}

.header-content {
    position: relative;
    display: inline-block;
}

h1 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.bio {
    font-size: 16px;
    color: #666;
    max-width: 600px;
    line-height: 1.8;
    margin: 0 auto 20px;
}

.edit-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 4px 8px;
    transition: color 0.2s;
}

.edit-btn:hover {
    color: #333;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    font-size: 14px;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.controls input[type="checkbox"] {
    cursor: pointer;
}

.btn-small {
    background: #333;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-small:hover {
    background: #555;
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 80px;
}

.piece {
    position: relative;
    aspect-ratio: 8.5 / 11;
    background: white;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    touch-action: none;
}

.piece:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.piece img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.piece-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 20px 16px;
    color: white;
    transform: translateY(100%);
    transition: transform 0.3s;
}

.piece:hover .piece-overlay {
    transform: translateY(0);
}

.piece-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.piece-notes {
    font-size: 12px;
    opacity: 0.9;
    line-height: 1.4;
}

.piece-edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.piece.edit-active .piece-edit-btn {
    opacity: 1;
}

.piece-edit-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 4px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-close:hover {
    color: #333;
}

#modal-image {
    width: 100%;
    display: block;
}

.modal-info {
    padding: 30px;
}

.modal-info h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.modal-info p {
    color: #666;
    line-height: 1.8;
}

/* Form modal */
.modal-form {
    padding: 40px;
}

.modal-form h2 {
    margin-bottom: 8px;
    font-size: 24px;
}

.form-hint {
    font-size: 13px;
    color: #999;
    margin-bottom: 20px;
}

.modal-form input,
.modal-form textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.modal-form input:focus,
.modal-form textarea:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(51, 51, 51, 0.1);
}

.modal-form textarea {
    min-height: 100px;
}

.btn {
    background: #333;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.btn:hover {
    background: #555;
}

.error {
    color: #d32f2f;
    font-size: 13px;
    margin-top: 12px;
}

/* Dragging */
.piece.dragging {
    opacity: 0.7;
    z-index: 100;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 24px 16px;
    }

    h1 {
        font-size: 36px;
    }

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

    .modal-form {
        padding: 24px;
    }
}
