:root {
    --bg-sidebar: #fbfbfc;
    --bg-main: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-light: #f3f4f6;
    --border-dark: #e5e7eb;
    --hover-bg: #f3f4f6;
    --accent-color: #111827;
    --primary-blue: #3b82f6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
    background-color: var(--bg-main); color: var(--text-primary); 
    display: flex; height: 100vh; overflow: hidden;
    user-select: none; 
}

#login-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #fafafa; z-index: 9999; display: flex; justify-content: center; align-items: center; }
.login-box { background: #fff; padding: 40px 32px 10px 32px; border-radius: 16px; box-shadow: 0 20px 40px -15px rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.05); width: 100%; max-width: 360px; text-align: center; }
.login-box p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.input-group { margin-bottom: 16px; text-align: left; }
.input-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; }
.input-group input, .input-group textarea { width: 100%; padding: 12px; border: 1px solid var(--border-dark); border-radius: 8px; font-size: 15px; outline: none; transition: border-color 0.2s; font-family: inherit; }
.input-group input:focus, .input-group textarea:focus { border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.login-btn { width: 100%; padding: 12px; background: var(--accent-color); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: transform 0.1s, opacity 0.2s; margin-top: 8px; }
.login-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.login-error { color: #ef4444; font-size: 13px; margin-top: 8px; min-height: 16px; }
.checkbox-group { display: flex; align-items: center; gap: 8px; margin-top: -4px; margin-bottom: 16px; cursor: pointer; }
.checkbox-group input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary-blue); }
.checkbox-group label { margin: 0; text-transform: none; font-size: 13px; font-weight: 500; cursor: pointer; }

#app-container { display: none; width: 100vw; height: 100vh; }

.sidebar { width: 260px; background-color: var(--bg-sidebar); border-right: 1px solid var(--border-dark); display: flex; flex-direction: column; padding: 24px 16px; flex-shrink: 0; transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1); overflow-x: hidden; position: relative; }

.sidebar-header { display: flex; align-items: center; justify-content: center; margin-bottom: 32px; min-height: 60px; }
.brand { display: flex; justify-content: center; width: 100%; }
.brand img { width: 45%; max-width: 90px; min-width: 36px; height: auto; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05)); }

.sidebar.collapsed { width: 72px; padding: 24px 12px; }
.sidebar.collapsed .brand img { width: 100%; max-width: 30px; } 
.sidebar.collapsed .nav-group-title { font-size: 10px; text-align: center; padding-left: 0; white-space: nowrap; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .user-profile { padding: 12px 0; }
.sidebar.collapsed .user-info-row { flex-direction: column; gap: 8px; }
.sidebar.collapsed .user-info-row > span { display: none; }
.sidebar.collapsed .user-actions { flex-direction: column; width: 100%; gap: 8px; }
.sidebar.collapsed .action-btn { width: 100%; justify-content: center; padding: 8px 0; }
.sidebar.collapsed .action-btn .nav-text { display: none; }

.nav-group-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; padding-left: 12px; transition: all 0.2s; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 4px; border-radius: 8px; color: var(--text-secondary); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; border: none; background: transparent; width: 100%; text-align: left; white-space: nowrap; }
.nav-item:hover { background-color: var(--hover-bg); color: var(--text-primary); }
.nav-item.active { background-color: var(--border-dark); color: var(--text-primary); font-weight: 600; }
.nav-item.hidden { display: none; }

.user-profile { margin-top: auto; padding: 12px; border-top: 1px solid var(--border-dark); display: flex; flex-direction: column; gap: 8px; }
.user-info-row { display: flex; justify-content: space-between; align-items: center; }
.user-actions { display: flex; gap: 6px; }
.action-btn { background: transparent; border: 1px solid var(--border-dark); padding: 4px 8px; border-radius: 6px; font-size: 12px; cursor: pointer; transition: all 0.2s; color: var(--text-secondary); display: flex; align-items: center; gap: 4px;}
.action-btn:hover { background: var(--hover-bg); color: var(--text-primary); }
.logout-btn:hover { background: #fee2e2; color: #ef4444; border-color: #fca5a5; }

.main-workspace { flex: 1; display: flex; flex-direction: column; background-color: var(--bg-main); overflow: hidden; position: relative; }

.sidebar-toggle-handle {
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 14px; height: 60px; background: #ffffff;
    border: 1px solid var(--border-dark); border-left: none; border-radius: 0 10px 10px 0;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    z-index: 1000; color: var(--text-secondary);
    box-shadow: 2px 0 8px rgba(0,0,0,0.03);
    transition: all 0.2s ease; outline: none;
}
.sidebar-toggle-handle:hover { background: var(--hover-bg); color: var(--primary-blue); width: 18px; }
.sidebar-toggle-handle .handle-icon { font-size: 10px; font-weight: bold; transition: transform 0.3s ease; }
.sidebar.collapsed ~ .main-workspace .sidebar-toggle-handle .handle-icon { transform: rotate(180deg); }

.topbar { height: 70px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; padding: 0 32px 0 24px; flex-shrink: 0; justify-content: space-between; }
.topbar-left { display: flex; align-items: center; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; margin-left: 8px; }
.bc-link { cursor: pointer; color: var(--text-secondary); transition: color 0.2s; }
.bc-link:hover { color: var(--text-primary); }
.bc-current { color: var(--text-primary); }
.bc-separator { color: #d1d5db; font-weight: 400; }

.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; margin-right: 16px; color: var(--text-primary); padding: 4px; transition: transform 0.3s; }

.btn-upload { padding: 8px 16px; background: var(--primary-blue); color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; gap: 6px; }
.btn-upload:hover { background: #2563eb; }
.btn-secondary { padding: 8px 16px; background: #ffffff; color: var(--text-primary); border: 1px solid var(--border-dark); border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.btn-secondary:hover { background: var(--hover-bg); border-color: #d1d5db; }
.btn-danger { padding: 8px 16px; background: #ef4444; color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.btn-danger:hover { background: #dc2626; }

.view-container { flex: 1; padding: 32px; overflow-y: auto; position: relative; display: flex; flex-direction: column; }
.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 24px; width: 100%; }

.item-card { 
    position: relative; background: #ffffff; border: 1px solid var(--border-dark); border-radius: 12px; 
    /* 💥 缩小默认的 padding，让没有角标的文件夹彻底居中、告别大脑门 */
    padding: 20px 16px; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; 
    cursor: pointer; transition: all 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.02); 
}

/* 💥 CSS 魔法 (:has选择器)：只有当卡片里面【存在】角标时，才给顶部额外增加留白 */
.item-card:has(.badge-container) {
    padding-top: 36px;
}


.item-card:hover { transform: translateY(-3px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05); border-color: #d1d5db; }
.item-icon { font-size: 48px; margin-bottom: 12px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05)); transition: filter 0.2s; }
.item-name { font-size: 14px; font-weight: 600; color: var(--text-primary); line-height: 1.4; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.status-msg { text-align: center; color: var(--text-secondary); margin-top: 60px; font-size: 15px; grid-column: 1/-1; }

.badge-container { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; }
.doc-badge { border-radius: 4px; font-size: 10px; padding: 2px 6px; font-weight: bold; border: 1px solid #f3f4f6;}

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.5); z-index: 10000; backdrop-filter: blur(2px); justify-content: center; align-items: center; }
.modal-overlay.show { display: flex; }
.modal-content { background: #fff; width: 90%; max-width: 400px; border-radius: 12px; padding: 24px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }
.modal-header { font-size: 18px; font-weight: 700; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center;}
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-secondary); border: none; background: none; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.btn-cancel { flex: 1; padding: 10px; background: #f3f4f6; color: var(--text-primary); border: none; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-save { flex: 1; padding: 10px; background: var(--primary-blue); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-save:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-danger-modal { flex: 1; padding: 10px; background: #ef4444; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; }

.select-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-dark); border-radius: 8px; font-size: 14px; outline: none; background: #f9fafb; color: var(--text-primary); cursor: pointer; }

.drawer-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.3); z-index: 10002; opacity: 0; transition: opacity 0.3s; }
.drawer-overlay.show { display: block; opacity: 1; }

.drawer-panel { 
    position: fixed; top: 0; right: 0; transform: translateX(100%); 
    width: 38.2vw; min-width: 450px; max-width: 800px; height: 100vh; 
    background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,0.1); 
    z-index: 10003; transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
    display: flex; flex-direction: column; 
}
.drawer-panel.show { transform: translateX(0); }
.drawer-header { padding: 20px 24px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; background: #f9fafb; }
.drawer-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.drawer-close { background: none; border: none; font-size: 24px; cursor: pointer; }

.drawer-content { 
    flex: 1; padding: 24px; overflow-y: auto; font-size: 14px; line-height: 1.8; 
    color: #374151; white-space: pre-wrap; word-break: break-all; 
    user-select: text; -webkit-user-select: text; 
}
.drawer-content pre { margin: 0 !important; border-radius: 8px !important; font-size: 13px !important; }

#custom-context-menu { display: none; position: fixed; z-index: 10001; background: #ffffff; border: 1px solid var(--border-dark); border-radius: 8px; padding: 6px; width: 180px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); flex-direction: column; }
.cm-item { padding: 10px 12px; font-size: 13px; color: var(--text-primary); border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background 0.1s; }
.cm-item:hover { background: #f3f4f6; color: var(--primary-blue); font-weight: 500; }
.cm-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

#toast-box { position: fixed; top: -50px; left: 50%; transform: translateX(-50%); background: #10b981; color: white; padding: 10px 20px; border-radius: 30px; font-size: 14px; font-weight: bold; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4); transition: top 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 10005; display: flex; align-items: center; gap: 8px; }
#toast-box.show { top: 30px; }

/* 💥 用户反馈专属 UI：底部发送框 */
.feedback-input-wrapper {
    position: fixed; bottom: 0; left: 260px; right: 0;
    padding: 20px 32px; background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px); border-top: 1px solid var(--border-dark);
    display: flex; gap: 16px; align-items: flex-end; transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50;
}
.sidebar.collapsed ~ .main-workspace .feedback-input-wrapper { left: 72px; }
.feedback-textarea { flex: 1; border: 1px solid var(--border-dark); border-radius: 12px; padding: 12px 16px; font-size: 14px; outline: none; background: #fff; resize: none; min-height: 44px; max-height: 120px; line-height: 1.6; transition: border-color 0.2s; font-family: inherit; }
.feedback-textarea:focus { border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.05); }

/* 💥 用户反馈评论区专属样式 */
.comment-section { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border-dark); }
.comment-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.comment-item { background: #f3f4f6; padding: 10px 14px; border-radius: 8px; font-size: 13px; color: #4b5563; }
.comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.comment-user { font-weight: 600; color: #111827; display: flex; align-items: center; gap: 6px; }
.comment-date { font-size: 11px; color: #9ca3af; }
.comment-input-area { display: flex; gap: 8px; margin-top: 8px; }
.comment-input { flex: 1; padding: 8px 12px; border: 1px solid var(--border-dark); border-radius: 8px; font-size: 13px; outline: none; transition: all 0.2s; background: #f9fafb;}
.comment-input:focus { border-color: var(--primary-blue); background: #fff; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.comment-btn { padding: 8px 16px; background: #e5e7eb; color: #4b5563; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.comment-btn:hover { background: var(--primary-blue); color: #fff; }

/* 💥 中转站：文件备注悬浮窗样式 (极简高级灰蓝 + 无尖角 + 呼吸动画) */
.item-card .remark-tooltip {
    /* 位置：挂在卡片正下方留出 6px 空隙 */
    position: absolute; top: calc(100% + 6px); left: 50%; 
    /* 初始状态：缩小到 95% */
    transform: translateX(-50%) scale(0.95);
    /* 颜色：低饱和度的高级灰蓝色，带有毛玻璃质感 */
    background: rgba(51, 65, 85, 0.95); backdrop-filter: blur(8px);
    /* 边框：加上 1px 的超细内发光边框，提升物理质感 */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc; padding: 12px 16px; border-radius: 12px;
    font-size: 13px; white-space: pre-wrap; width: max-content; max-width: 240px;
    opacity: 0; visibility: hidden; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); 
    z-index: 50; pointer-events: none; text-align: left; line-height: 1.6; 
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15); 
}

/* 悬浮时的动画：轻微放大并浮现，极具呼吸感 */
.item-card:hover .remark-tooltip { 
    opacity: 1; visibility: visible; transform: translateX(-50%) scale(1); 
}

/* 📝 右下角提示小图标的样式保持不变 */
.remark-indicator { 
    position: absolute; bottom: 12px; right: 12px; font-size: 14px; opacity: 0.8; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); 
}

@media (max-width: 768px) {
    /* 1. 侧边栏及遮罩适配 */
    .sidebar { position: fixed; top: 0; left: -280px; height: 100vh; z-index: 1000; box-shadow: 4px 0 24px rgba(0,0,0,0.1); }
    .sidebar.show { left: 0; } 
    .mobile-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.4); z-index: 900; }
    .mobile-overlay.show { display: block; }
    .sidebar-toggle-handle { display: none; } 
    
    /* 💥 2. 顶部导航栏（单行紧凑模式） */
    .topbar { padding: 0 !important; height: auto !important; min-height: 56px !important; }
    .topbar > div:not(#mapping-warning) { 
        display: flex !important; 
        align-items: center !important; 
        justify-content: space-between !important;
        padding: 8px 12px !important; 
        height: auto !important;
        width: 100%;
        gap: 8px;
    }
    
    /* 💥 3. 左侧区域 (含菜单和路径) - 必须加 min-width: 0 才能让长路径滚动而不撑爆外层 */
    .topbar-left { 
        display: flex !important; 
        align-items: center !important; 
        flex: 1; 
        min-width: 0; 
        gap: 8px;
    }
    
    /* 三横杠菜单按钮 - 缩小并靠左 */
    .mobile-menu-btn { 
        display: block; 
        font-size: 20px !important; 
        padding: 4px !important; 
        margin: 0 !important; 
        flex-shrink: 0; /* 防止按钮被长路径挤压变形 */
    }
    
    /* 💥 4. 面包屑路径 - 变成中间的滑动轨道 */
    .breadcrumb { 
        display: flex; align-items: center;
        flex: 1; 
        overflow-x: auto; 
        white-space: nowrap; 
        font-size: 14px; 
        margin: 0; padding-bottom: 0;
        /* 隐藏滚动条让视觉更干净 */
        -ms-overflow-style: none; scrollbar-width: none;
    }
    .breadcrumb::-webkit-scrollbar { display: none; }
    
    /* 文字隐身术：将“板块首页”隐藏，仅保留小房子图标 */
    .breadcrumb .bc-link:first-child { font-size: 0; }
    .breadcrumb .bc-link:first-child::before { content: '🏠'; font-size: 15px; }
    
    /* 💥 5. 操作按钮 - 保持在最右侧同一行 */
    #action-container { 
        display: flex; align-items: center;
        gap: 6px !important; 
        flex-shrink: 0; 
    }
    .btn-upload, .btn-secondary, .btn-danger { 
        font-size: 0 !important; 
        padding: 8px !important; 
        min-width: 34px !important; height: 34px !important;
        display: flex; align-items: center; justify-content: center;
    }
    .btn-upload span, .btn-secondary span, .btn-danger span { font-size: 16px !important; display: block; } 

    /* 6. 移动端智能流式卡片排版 */
    .view-container { padding: 12px; }
    .grid-view { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
    
    /* 💥 强制取消移动端的“大脑门”，所有卡片恢复紧凑内边距 */
    .item-card { padding: 16px 10px !important; justify-content: center; } 
    .item-icon { font-size: 38px; margin-bottom: 8px; } 
    
    /* 💥 革命性排版：取消角标的绝对定位！让它变成正常的元素，自己往下“推”图标 */
    .badge-container { 
        position: relative !important; 
        top: 0 !important; left: 0 !important; transform: none !important; 
        width: 100%; justify-content: center; flex-wrap: wrap; gap: 4px; 
        margin-bottom: 8px; /* 这一步会自然地把下面的文件图标往下推开，永不重叠 */
    }
    .doc-badge { font-size: 9px; padding: 2px 4px; }
    
    /* 7. 其他适配 */
    .drawer-panel { width: 100%; min-width: 100%; } 
    .modal-content { width: 92%; padding: 20px; }
    .feedback-input-wrapper { left: 0 !important; right: 0 !important; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    #changelog-view, #feedback-view { padding-left: 0 !important; padding-right: 0 !important; }
    #changelog-list { margin-left: 0 !important; padding-left: 16px !important; }
    .item-card .remark-tooltip { max-width: 200px; font-size: 12px; padding: 10px 12px; }
}

#custom-context-menu .cm-divider:last-child {
    display: none !important;
}

/* ==========================================
   自定义图标弹窗专属样式 
========================================== */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    background: #fcfcfd;
}

/* 隐藏滚动条让视觉更干净 */
.emoji-grid::-webkit-scrollbar { width: 6px; }
.emoji-grid::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.emoji-item {
    font-size: 26px;
    text-align: center;
    padding: 6px 0;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    user-select: none;
}

.emoji-item:hover {
    background: #e5e7eb;
    transform: scale(1.15);
}

.emoji-item.selected {
    border-color: var(--primary-blue);
    background: #eff6ff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* 💥 专门针对手机移动端的无框体顶格“选项条”优化 */
@media (max-width: 768px) {
    /* 1. 清空外层容器的左右留白，让内容可以直接顶到手机屏幕边缘 */
    .act-list-container {
        padding: 16px 0px !important;
    }

    /* 2. 卡片扁平化：去掉左右边框、去掉圆角、去掉阴影，变成上下排布的选项条 */
    .act-card {
        border-left: none !important;
        border-right: none !important;
        border-radius: 0px !important;
        box-shadow: none !important;
        margin-bottom: 10px !important;
        border-top: 1px solid var(--border-dark) !important;
        border-bottom: 1px solid var(--border-dark) !important;
    }

    /* 3. 内部元素（标题栏和展开内容）重新加上适当的左右内边距，防止文字死贴着屏幕 */
    .act-header {
        padding: 16px !important;
    }
    
    .act-body {
        padding: 0 16px 20px 16px !important;
    }

    .act-layout {
        gap: 16px !important;
    }
}