/* ==========================================================================
   1. 基础全局复位与变量设定
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #f7f7f7;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent-color: #ffb7c5;
    --accent-hover: #ff99aa;
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', 'Noto Sans SC', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   2. 通用原子组件 (按钮、弹窗、Loading、Toast)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: #eee;
    color: #666;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ffebeb;
    color: #ff4d4f;
}

.btn-danger:hover {
    background: #ff4d4f;
    color: white;
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 99999;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 99990;
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 开关组件与表单控制 */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* ==========================================================================
   3. 核心骨架布局 (侧边栏 & 主内容区)
   ========================================================================== */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    padding: 25px 15px;
    flex-shrink: 0;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 30px;
    padding-left: 10px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255, 183, 197, 0.1);
    color: var(--text-primary);
    font-weight: bold;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.sync-status {
    font-size: 11px;
    color: #999;
    text-align: center;
    margin-top: 8px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 25px;
    overflow: hidden;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-shrink: 0;
}

.view-pane {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.view-pane.active {
    display: block;
}

/* ==========================================================================
   4. 手账本面板专属区域
   ========================================================================== */
#pane-diary.view-pane.active {
    display: flex;
}

.diary-layout {
    display: flex;
    gap: 20px;
    height: 100%;
    width: 100%;
}

.diary-list-panel {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex-shrink: 0;
}

.diary-card {
    background: white;
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.diary-card.active {
    border-color: var(--accent-color);
}

.diary-card-body {
    flex: 1;
    min-width: 0;
}

.diary-card .title {
    font-size: 16px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.diary-card .meta {
    font-size: 12px;
    color: #999;
}

/* 日记卡片独立删除按钮 */
.diary-delete-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ffebeb;
    color: #ff4d4f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    user-select: none;
    margin-left: 10px;
    flex-shrink: 0;
}

.diary-card:hover .diary-delete-btn {
    opacity: 1;
    transform: scale(1);
}

.diary-delete-btn:hover {
    background: #ff4d4f;
    color: white;
    transform: scale(1.1) !important;
}

/* 编辑器样式（含手账本稿纸底纹） */
.diary-editor-panel {
    flex: 1;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.editor-title {
    border: none;
    font-size: 22px;
    font-weight: bold;
    outline: none;
    font-family: inherit;
    color: var(--text-primary);
}

.editor-content {
    border: none;
    flex: 1;
    font-size: 16px;
    line-height: 1.8;
    outline: none;
    resize: none;
    font-family: inherit;
    color: var(--text-primary);
    background-image: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 96%, rgba(255, 183, 197, 0.3) 96%, rgba(255, 183, 197, 0.3) 100%);
    background-size: 100% 1.8em;
    background-attachment: local;
    padding-top: 5px;
}

/* ==========================================================================
   5. 创意工具箱专属区域 (美化升级：标题精简字号、默认居中、Hover平滑移位)
   ========================================================================== */
.box1 {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.box1_title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

.title-actions {
    display: flex;
    gap: 15px;
    font-size: 13px;
}

.add-btn-icon, .sort-btn-icon {
    cursor: pointer;
    color: #999;
    user-select: none;
    transition: color 0.2s;
}

.add-btn-icon:hover { color: var(--accent-hover); }
.sort-btn-icon:hover, .sort-btn-icon.active { color: #333; font-weight: bold; }

/* 紧凑精致网格 */
.box1_content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
}

/* 16:10 黄金比例卡片 */
.tool-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: transform 0.2s;
    aspect-ratio: 16 / 10;
}

.tool-card:hover {
    transform: translateY(-2px);
}

.tool-card a {
    display: flex;
    flex-direction: column;
    justify-content: center; 
    align-items: center;     /* 默认水平居中 */
    padding: 12px;           
    width: 100%;
    height: 100%;            
    color: white;
    text-decoration: none;
    position: relative;
    z-index: 1;
    text-align: center;
}

.tool-card a img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.3;
    z-index: -1;
}

/* 精雕细琢的卡片标题：缩小字号至 12px 更加清秀，且默认完全居中 */
.tool-card h1 { 
    font-size: 12px;          /* 缩小字号，让其更加秀气高级 */
    font-weight: 600;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateY(10px); /* 默认向下偏移，配合 Flex 实现完美的正中央定位 */
}

/* Hover 时标题平滑向上滑动 */
.tool-card:hover h1 {
    transform: translateY(-2px);
}

/* 卡片描述文字 */
.tool-card p { 
    font-size: 11px; 
    width: 100%;
    opacity: 0;                 
    transform: translateY(10px); 
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.tool-card:hover p {
    opacity: 0.9;               
    transform: translateY(0);   
}

/* 操作按钮盒 */
.card-action-box {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
    opacity: 0;                 
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tool-card:hover .card-action-box {
    opacity: 1;
    transform: scale(1);
}

.card-btn {
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.sorting-mode .tool-card {
    animation: shake 0.3s ease infinite alternate;
}

@keyframes shake {
    0% { transform: rotate(-0.5deg); }
    100% { transform: rotate(0.5deg); }
}

/* ==========================================================================
   6. 灵感照片墙专属区域
   ========================================================================== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.image-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.image-card:hover img {
    transform: scale(1.04);
}

.image-card .upload-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    border: 2px dashed #eee;
    border-radius: var(--border-radius);
    transition: background 0.2s;
}

.image-card .upload-placeholder:hover {
    background: rgba(255, 183, 197, 0.05);
}

/* 右上角悬浮删除按钮 */
.image-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #ff4d4f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.25s ease;
    z-index: 5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    user-select: none;
}

.image-card:hover .image-delete-btn {
    opacity: 1;
    transform: scale(1);
}

.image-delete-btn:hover {
    background: #ff4d4f;
    color: white;
    transform: scale(1.1) !important;
}

/* 高保真全屏大图预览遮罩层 Lightbox */
.gallery-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.gallery-preview-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.gallery-preview-overlay img {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.gallery-preview-overlay.active img {
    transform: scale(1);
}

.gallery-preview-close {
    position: absolute;
    top: 25px;
    right: 30px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    user-select: none;
}

.gallery-preview-close:hover {
    color: #ffffff;
    transform: scale(1.1);
}

/* ==========================================================================
   7. 实验室中心设置层与模态弹窗弹层
   ========================================================================== */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #f9f9f9;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: white;
    width: 440px;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.modal-box .form-control {
    width: 100%;
}

.modal-title { font-size: 18px; font-weight: bold; margin-bottom: 20px; }

.toggle-more-btn {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin: 15px 0;
    cursor: pointer;
    user-select: none;
}

.modal-more-drawer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.modal-more-drawer.expanded {
    max-height: 300px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

#modal-delete-btn { margin-right: auto; }

/* ==========================================================================
   8. 响应式布局自适应 (手机移动端优化)
   ========================================================================== */
@media screen and (max-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .image-delete-btn {
        opacity: 1;
        transform: scale(1);
    }
    .tool-card h1 {
        transform: translateY(0) !important;
    }
    .tool-card p, .card-action-box {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}