:root {
    --primary: #ff9f43;
    --primary-dark: #e67e22;
    --bg: #fdf6e3;
    --card-bg: #ffffff;
    --text: #5d4037;
    --gray: #b0bec5;
    --shadow: 0 4px 15px rgba(139, 69, 19, 0.15);
    --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Nunito', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    padding-top: 80px; /* Header space */
}

/* Header */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-dark);
    margin-right: 20px;
}

.search-bar { flex: 1; max-width: 500px; margin: 0 20px; }
.search-bar input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 2px solid #eee;
    outline: none;
    transition: 0.3s;
}
.search-bar input:focus { border-color: var(--primary); }

.admin-toggle button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s;
}
.admin-toggle button:hover { transform: scale(1.05); }

/* Filter Bar */
.filter-bar {
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-tag {
    padding: 6px 14px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 15px;
    cursor: pointer;
    transition: 0.3s;
    user-select: none;
}
.filter-tag:hover { border-color: var(--primary); }
.filter-tag.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Masonry Layout */
.gallery-container {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

.masonry {
    column-count: 4; /* Default desktop */
    column-gap: 20px;
}

@media (max-width: 1200px) { .masonry { column-count: 3; } }
@media (max-width: 900px) { .masonry { column-count: 2; } }
@media (max-width: 600px) { .masonry { column-count: 1; } }

.card {
    break-inside: avoid;
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    animation: fadeIn 0.5s ease-up;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.25);
}

.card-img-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.card img {
    width: 100%;
    display: block;
    transition: filter 0.3s;
}

.card.blurred img {
    filter: blur(15px);
}
.card.blurred:hover img {
    filter: blur(0);
}

.card-info {
    padding: 15px;
}

.card-title {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 1rem;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.card-tag {
    font-size: 0.75rem;
    background: #eee;
    padding: 2px 8px;
    border-radius: 4px;
    color: #666;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.price-tag {
    color: var(--primary-dark);
    font-weight: bold;
    font-size: 1.1rem;
}

.delete-btn {
    opacity: 0;
    color: red;
    cursor: pointer;
    font-size: 0.9rem;
    background: none; border: none;
}
body.admin-mode .delete-btn { opacity: 1; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}
.modal.open { display: flex; }

.modal-content {
    background: white;
    padding: 25px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: popIn 0.3s;
}

.close-modal {
    position: absolute;
    right: 20px; top: 15px;
    font-size: 28px;
    cursor: pointer;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}
.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: bold;
    color: #888;
}
.tab-btn.active {
    border-bottom-color: var(--primary);
    color: var(--primary-dark);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Upload Area */
.upload-area {
    border: 3px dashed #ddd;
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: #888;
    cursor: pointer;
    transition: 0.2s;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: #fffdf5;
}

.upload-list-item {
    display: flex;
    align-items: center;
    background: #f9f9f9;
    padding: 10px;
    margin-top: 10px;
    border-radius: 8px;
    gap: 10px;
    flex-wrap: wrap;
}
.upload-list-item input[type="text"] {
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.upload-list-item .tags-select {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.select-tag-chip {
    padding: 2px 8px;
    border: 1px solid #ccc;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
}
.select-tag-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Tag Settings */
.tag-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
}
/* 新增编辑按钮样式 */
.edit-btn {
    opacity: 0;
    color: var(--primary-dark);
    cursor: pointer;
    font-size: 0.9rem;
    background: none; border: none;
    transition: opacity 0.3s;
}

body.admin-mode .delete-btn,
body.admin-mode .edit-btn { 
    opacity: 1; 
}

/* 模态框样式调整 */
.small-modal {
    max-width: 450px;
}
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
}
.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }