/* ===== 粉色主题样式 ===== */
:root {
    --pink-50:  #fff5f8;
    --pink-100: #ffe4ee;
    --pink-200: #ffc9dd;
    --pink-300: #ffa6c9;
    --pink-400: #ff7fae;
    --pink-500: #ff5c93;
    --pink-600: #f03e7a;
    --pink-700: #c92b5e;
    --text:     #4a2c38;
    --text-light: #8a6b78;
    --bg:       #fff5f8;
    --white:    #ffffff;
    --radius:   14px;
    --shadow:   0 4px 16px rgba(240, 62, 122, 0.12);
    --shadow-hover: 0 6px 22px rgba(240, 62, 122, 0.22);
}

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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, var(--pink-50) 0%, var(--pink-100) 100%);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ===== 前端 ===== */
.app {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 14px 40px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 4px 12px;
    background: linear-gradient(180deg, rgba(255,245,248,0.96), rgba(255,245,248,0.85));
    backdrop-filter: blur(8px);
}
.app-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}
.app-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--pink-600);
    text-shadow: 0 1px 0 #fff;
    flex: 1;
}

.admin-entry {
    font-size: 22px;
    color: var(--pink-400);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: var(--shadow);
    transition: transform .2s;
}
.admin-entry:active { transform: scale(0.9); }

/* 一键分享按钮 */
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, var(--pink-500), var(--pink-600));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    -webkit-tap-highlight-color: transparent;
}
.share-btn:active { transform: scale(0.92); }
.share-icon { font-size: 15px; line-height: 1; }

/* 分享反馈提示 */
.toast {
    position: fixed;
    left: 50%;
    bottom: 38px;
    transform: translateX(-50%) translateY(20px);
    background: rgba(74, 44, 56, 0.92);
    color: #fff;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 22px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 1100;
    max-width: 80vw;
    text-align: center;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 分类导航 */
.category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.category-chip {
    padding: 7px 16px;
    border-radius: 20px;
    background: var(--white);
    color: var(--pink-600);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: 1.5px solid var(--pink-200);
    white-space: nowrap;
    transition: all .2s;
    box-shadow: var(--shadow);
}
.category-chip.active {
    background: linear-gradient(135deg, var(--pink-500), var(--pink-600));
    color: #fff;
    border-color: var(--pink-600);
}

/* 图片网格 */
.gallery { padding: 4px 0 20px; }

/* 分类图片上方的文本描述 */
.category-desc {
    margin: 6px 0 16px;
    padding: 0 2px;
}
.category-desc-inner {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px 18px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.75;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--pink-500);
    white-space: pre-wrap;
    word-break: break-word;
}

/* 图片网格：auto-fit 自适应列数，1张图铺满、多张均分，按比例自动铺满 */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    align-items: start;
    gap: 10px;
}

.gallery-item {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}
.gallery-item:active { transform: scale(0.98); }

.gallery-item img {
    width: 100%;
    /* 统一缩略图尺寸：固定正方形比例，不同尺寸图片都裁剪铺满显示 */
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    display: block;
    background: var(--pink-50);
    cursor: zoom-in;
}

/* 单图分类：不固定长宽高，按图片原始比例完整显示 */
.gallery-grid.single .gallery-item img {
    aspect-ratio: auto;
    height: auto;
    object-fit: contain;
}

/* 提示可点击放大的角标（移动端没有 cursor 提示） */
.gallery-item::after {
    content: '🔍';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    font-size: 14px;
    background: rgba(74, 44, 56, 0.55);
    color: #fff;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
}
.gallery-item:hover::after,
.gallery-item:active::after {
    opacity: 1;
    transform: scale(1);
}

.gallery-item figcaption {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-light);
    border-top: 1px solid var(--pink-100);
    word-break: break-all;
}

.empty-gallery {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-light);
}
.empty-icon { font-size: 48px; margin-bottom: 10px; }

/* 分页 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}
.page-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--white);
    color: var(--pink-600);
    border: 1.5px solid var(--pink-200);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    transition: all .2s;
}
.page-btn:hover { border-color: var(--pink-400); }
.page-btn:active { transform: scale(0.96); }
.page-btn.disabled {
    color: #cbb3bc;
    background: #faf0f4;
    border-color: var(--pink-100);
    cursor: not-allowed;
    box-shadow: none;
}
.page-info {
    font-size: 13px;
    color: var(--text-light);
    padding: 0 4px;
}
@media (max-width: 768px) {
    .category-nav{
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
/* 公告 */
.announcement {
    margin-top: 20px;
    padding: 0 2px;
}
.announcement-bar {
    background: linear-gradient(135deg, var(--pink-400), var(--pink-600));
    color: #fff;
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}
.announcement-tag {
    background: rgba(255,255,255,0.25);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.announcement-text {
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
}

.empty-tip { color: var(--text-light); font-size: 14px; }

/* ===== 图片放大查看器 ===== */
.image-viewer {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(40, 10, 25, 0.92);
    z-index: 1000;
    overflow: hidden;
    touch-action: none;
}
.image-viewer.active { display: block; }

.viewer-canvas {
    position: absolute;
    inset: 0;
    cursor: zoom-in;
}
.viewer-canvas.zoomed { cursor: grab; }
.viewer-canvas.zoomed:active { cursor: grabbing; }

.image-viewer img {
    position: absolute;
    left: 50%;
    top: 50%;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    transform: translate(-50%, -50%);
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    /* 放大时尽量用高质量重采样 */
    image-rendering: auto;
}

.viewer-close {
    position: absolute;
    top: 18px;
    right: 22px;
    color: #fff;
    font-size: 42px;
    line-height: 1;
    cursor: pointer;
    background: rgba(255,255,255,0.15);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

/* ===== 登录页 ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 36px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-hover);
    text-align: center;
}
.login-icon { font-size: 48px; margin-bottom: 8px; }
.login-card h2 { color: var(--pink-600); margin-bottom: 18px; }
.login-error { color: #e63946; font-size: 14px; margin-bottom: 12px; }
.login-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--pink-200);
    border-radius: 10px;
    font-size: 15px;
    margin-bottom: 14px;
    outline: none;
    transition: border-color .2s;
}
.login-input:focus { border-color: var(--pink-500); }
.back-link {
    display: inline-block;
    margin-top: 16px;
    color: var(--pink-400);
    text-decoration: none;
    font-size: 14px;
}

/* ===== 通用按钮 ===== */
.btn-primary, .btn-ghost, .btn-mini, .btn-danger {
    cursor: pointer;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--pink-500), var(--pink-600));
    color: #fff;
    padding: 11px 22px;
    box-shadow: var(--shadow);
}
.btn-primary:hover { box-shadow: var(--shadow-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-ghost {
    background: var(--white);
    color: var(--pink-600);
    padding: 8px 14px;
    text-decoration: none;
    border: 1.5px solid var(--pink-200);
    font-size: 13px;
}
.btn-mini {
    background: var(--pink-100);
    color: var(--pink-700);
    padding: 5px 12px;
    font-size: 12px;
}
.btn-danger {
    background: #ffe0e6;
    color: #d63354;
    padding: 5px 12px;
    font-size: 12px;
}

/* ===== 后台管理 ===== */
.admin-body { background: var(--pink-50); }
.admin-header {
    background: linear-gradient(135deg, var(--pink-500), var(--pink-600));
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: var(--shadow);
}
.admin-header h1 { font-size: 20px; }
.admin-actions { display: flex; gap: 8px; }
.admin-actions .btn-ghost {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-color: rgba(255,255,255,0.4);
}

.admin-main {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 14px 40px;
}

.panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.panel-title {
    color: var(--pink-600);
    font-size: 17px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px dashed var(--pink-100);
}

.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .inline-form { display: flex; flex-direction: column; gap: 5px;
    font-size: 13px; color: var(--text-light); font-weight: 500; }
.inline-form { flex-direction: row; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 160px; }

.input, .input-sm {
    padding: 9px 12px;
    border: 1.5px solid var(--pink-200);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
    color: var(--text);
    background: var(--pink-50);
}
.input:focus, .input-sm:focus { border-color: var(--pink-500); background: #fff; }
.input-sm { padding: 5px 8px; font-size: 13px; }
.desc-textarea { min-height: 52px; line-height: 1.5; resize: vertical; }
.file-input { font-size: 13px; }

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 14px;
    font-size: 13px;
    table-layout: fixed;
}
.data-table th, .data-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--pink-100);
    vertical-align: middle;
    word-break: break-word;
}
/* ID/数字列：左右间距更小 */
.data-table th:first-child,
.data-table td:first-child,
.data-table th:nth-child(4),
.data-table td:nth-child(4),
.data-table th:nth-child(5),
.data-table td:nth-child(5) {
    padding-left: 6px;
    padding-right: 6px;
    text-align: center;
}
/* 操作列：右对齐按钮、左间距更小 */
.data-table th:last-child,
.data-table td:last-child {
    padding-left: 4px;
    padding-right: 8px;
}
/* 描述文本列：左间距更小，给文本区更多空间 */
.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    padding-left: 4px;
    padding-right: 8px;
}
.data-table th {
    color: var(--pink-600);
    font-weight: 600;
    background: var(--pink-50);
    white-space: nowrap;
}
.data-table td .input-sm,
.data-table td .desc-textarea {
    width: 100%;
    box-sizing: border-box;
}
.data-table td .input-sm[type="number"] {
    width: 100%;
    text-align: center;
}
.data-table td form {
    display: inline;
    margin: 0;
}
.data-table td.row-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    height: 100%;
}
.data-table td.row-actions .row-actions {
    width: 100%;
}
.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
}
.row-actions form { margin: 0; }

.admin-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 10px;
}
.admin-gallery-item {
    background: var(--pink-50);
    border-radius: 10px;
    padding: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.admin-gallery-item img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 6px;
    background: #fff;
}
.admin-gallery-info { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.cat-badge {
    align-self: flex-start;
    background: var(--pink-200);
    color: var(--pink-700);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.img-desc { color: var(--text); word-break: break-all; }
.img-time { color: var(--text-light); font-size: 11px; }
.admin-gallery-item form { text-align: right; }

.help-text { font-size: 13px; color: var(--text-light); margin-bottom: 10px; }
.backup-actions { margin-bottom: 6px; }
.divider {
    border: none;
    border-top: 1px dashed var(--pink-200);
    margin: 18px 0;
}

/* ===== 响应式：大屏两列图片，小屏单列也可 ===== */
@media (min-width: 600px) {
    .app-title { font-size: 26px; }
}

@media (max-width: 400px) {
    .gallery-grid { gap: 8px; }
    .app-title { font-size: 19px; }
    .announcement-text { font-size: 13px; }
}
