:root { --dash-sidebar: #1b1e2d; --dash-header: #1f2233; --dash-accent: #7c5cff; --dash-accent-strong: #5a3bff; --dash-bg: #f4f6f9; --dash-surface: #ffffff; --dash-muted: #8a90a2; --topbar-height: 64px; }
body { background-color: var(--dash-bg); font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif; overflow: hidden; margin: 0; color: #1f2333; }
.hidden { display: none !important; }

/* 布局 */
.app-layout { display: flex; flex-direction: column; height: 100vh; }
.main-wrapper { display: flex; flex: 1; overflow: hidden; }

/* 浮动菜单按钮 */
.float-menu-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: rgba(31, 34, 51, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: 0.3s;
}
.float-menu-btn:hover {
    background: var(--dash-accent);
    color: #0c0a20;
    transform: scale(1.05);
}
/* 侧边栏打开时，浮动按钮变为透明或隐藏，避免与侧栏内关闭按钮冲突 */
body.sidebar-open .float-menu-btn {
    opacity: 0;
    pointer-events: none;
}

/* Sidebar 样式 */
.sidebar { 
    position: fixed; 
    top: 0; 
    left: 0; 
    bottom: 0; 
    height: 100vh; /* Fallback */
    height: 100dvh; /* Mobile viewport height fix */
    width: 280px; 
    background: linear-gradient(180deg, #1b1e2d 0%, #171a28 100%); 
    color: #fff; 
    padding: 0; 
    box-shadow: 8px 0 20px rgba(12, 14, 26, 0.18); 
    transform: translateX(-100%); 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    z-index: 200; 
    display: flex;
    flex-direction: column;
}

body.sidebar-open .sidebar { transform: translateX(0); }
.sidebar-backdrop { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(13, 12, 20, 0.45); opacity: 0; pointer-events: none; transition: 0.2s; z-index: 180; }
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

/* 大屏幕布局优化 */
@media (min-width: 1024px) {
    /* 默认状态：改为展开侧边栏 */
    .sidebar { transform: translateX(0) !important; } 
    /* 修改：固定侧边栏宽度，不再允许动态收缩 */
    .app-layout { padding-left: 280px !important; transition: none; }
    
    /* 忽略 .sidebar-open 类，强制展开 */
    body:not(.sidebar-open) .sidebar { transform: translateX(0) !important; }
    
    /* 遮罩层在大屏下始终隐藏 */
    .sidebar-backdrop { display: none !important; }
    
    /* 隐藏汉堡按钮和关闭按钮 */
    .float-menu-btn { display: none !important; }
    .hamburger-btn { display: none !important; }
    
    /* 针对特殊页面隐藏侧边栏的逻辑 (Diary Editor 等) */
    body.no-sidebar .sidebar { transform: translateX(-100%) !important; }
    body.no-sidebar .app-layout { padding-left: 0 !important; }
}

/* 针对特殊页面隐藏侧边栏的逻辑 (优先级更高) */
body.no-sidebar .sidebar { transform: translateX(-100%) !important; }
body.no-sidebar .app-layout { padding-left: 0 !important; }
body.no-sidebar .float-menu-btn { display: none !important; }

/* Sidebar Header */
.sidebar-header {
    padding: 25px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    height: 80px; /* 固定高度确保布局稳定 */
    box-sizing: border-box;
    background: linear-gradient(180deg, #1b1e2d 0%, #191c2a 100%);
    position: sticky;
    top: 0;
    z-index: 2;
}
.brand { font-size: 18px; font-weight: 700; color: #d8d3ff; letter-spacing: 1px; }
.hamburger-btn { 
    background: transparent; 
    border: none; 
    color: rgba(255,255,255,0.8); 
    font-size: 24px; 
    cursor: pointer; 
    padding: 5px;
    width: 40px; 
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.hamburger-btn:hover { color: white; }

/* Sidebar Nav */
.sidebar nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    --nav-main: var(--dash-accent);
    --nav-main-opacity: rgba(124, 92, 255, 0.12);
    --glider-top: 0px;
    --glider-height: 0px;
}
.nav-glider-container {
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 1px;
    pointer-events: none;
}
.nav-glider {
    position: absolute;
    left: 0;
    width: 1px;
    height: var(--glider-height);
    transform: translateY(var(--glider-top));
    background: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, var(--nav-main) 50%, rgba(0, 0, 0, 0) 100%);
    transition: transform 0.5s cubic-bezier(0.37, 1.95, 0.66, 0.56), height 0.3s ease;
}
.nav-glider::before {
    content: "";
    position: absolute;
    height: 60%;
    width: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--nav-main);
    filter: blur(10px);
}
.nav-glider::after {
    content: "";
    position: absolute;
    left: 0;
    height: 100%;
    width: 150px;
    background: linear-gradient(90deg, var(--nav-main-opacity) 0%, rgba(0, 0, 0, 0) 100%);
}
.nav-btn { 
    display: flex; 
    align-items: center; 
    gap: 10px;
    width: 100%; 
    padding: 14px 16px; 
    margin-bottom: 8px; 
    background: transparent; 
    border: none; 
    color: #b1b5c8; 
    text-align: left; 
    cursor: pointer; 
    border-radius: 12px; 
    transition: 0.2s; 
    font-weight: 600; 
    font-size: 15px;
    flex-shrink: 0; /* 防止被压缩 */
}
.nav-btn:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-btn.active { color: var(--dash-accent); }
.nav-illus {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}
.sidebar-illus {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

/* Sidebar Footer (Profile) */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.1);
    margin-top: auto; /* 确保推到底部 */
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.btn-sidebar-auth {
    width: 100%;
    padding: 12px;
    background: var(--dash-accent);
    color: #0c0a20;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    line-height: 1;
}
.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
}
.user-badge:hover { background: rgba(255,255,255,0.1); }
.btn-sidebar-logout {
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.6);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
}
.btn-sidebar-logout:hover { border-color: #ff4757; color: #ff4757; }

/* Workspace */
#workspace { flex: 1; background-color: var(--dash-bg); padding: clamp(20px, 4vw, 40px); overflow-y: auto; z-index: 1; padding-top: 80px; /* 为浮动按钮留出空间 */ }

/* Modal 弹窗 */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(13, 12, 20, 0.7); backdrop-filter: blur(6px); z-index: 999; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: 0.3s; }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.auth-card { background: #1b1e2d; width: min(420px, 92vw); padding: 36px; border-radius: 18px; border: 1px solid rgba(255,255,255,0.1); text-align: center; color: white; transform: translateY(30px); transition: 0.3s; box-shadow: 0 18px 40px rgba(8, 9, 18, 0.45); }
.modal-overlay.show .auth-card { transform: translateY(0); }
.form-group input { width: 100%; padding: 12px 14px; margin-bottom: 18px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.12); color: white; border-radius: 10px; outline: none; }
.btn-submit { width: 100%; padding: 12px; background: linear-gradient(135deg, var(--dash-accent), var(--dash-accent-strong)); color: #0c0a20; font-weight: 700; border: none; border-radius: 10px; cursor: pointer; }

@media (max-width: 1200px) {
  .sidebar { width: 240px; }
}

@media (max-width: 900px) {
  .sidebar { width: 280px; max-width: 80vw; }
  /* 确保移动端 nav 高度自适应，剩余空间分配给 nav，从而把 footer 挤到底部 */
  .sidebar nav { 
    display: flex; 
    flex-direction: column; 
    overflow-y: auto; 
    padding: 20px 12px; 
    flex: 1; 
  }
  .nav-btn { margin-bottom: 8px; white-space: normal; padding: 14px 16px; }
}

@media (max-width: 640px) {
  .float-menu-btn { top: 15px; left: 15px; width: 40px; height: 40px; font-size: 20px; }
  #workspace { padding: 16px; padding-top: 70px; }
}
