/* 全局重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* 🌈 色彩系统 */
    --bg-body: #F0F0F0;
    /* 温润灰色背景 */
    --bg-card: rgba(255, 255, 255, 0.9);
    /* 卡片背景 */
    --bg-glass: rgba(255, 255, 255, 0.7);
    /* 毛玻璃背景 */

    --color-primary: #007AFF;
    /* 苹果蓝 */
    --color-primary-hover: #0062cc;
    --color-accent: #FF9500;
    /* 活力橙 */

    --text-primary: #1D1D1F;
    /* 主要文字 */
    --text-secondary: #86868B;
    /* 次要文字 */

    /* 🌑 投影系统 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.12);
    --shadow-inset: inset 0 1px 3px rgba(0, 0, 0, 0.06);

    /* 🎪 动画曲线 */
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);

    /* 📐 布局变量 */
    --grid-margin: 0px;
    --module-padding: 0px;
    --container-padding: 20px;
    --radius-lg: 20px;
    --radius-md: 12px;
    --top-bar-height: 70px;
    /* Global reference */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background-color: var(--bg-body);
    background-image: linear-gradient(180deg, #FFFFFF 0%, var(--bg-body) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* 顶部导航栏 */
.top-bar {
    background: transparent;
    height: var(--top-bar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 10000;
    /* Ensure higher than trigger zone (9999) */
    position: sticky;
    top: 0;
    /* Ensure absolute children (like centered logo) position relative to this */
    /* Ensure on top of everything except modals */
    transition: background 0.3s var(--ease-smooth),
        backdrop-filter 0.3s var(--ease-smooth),
        box-shadow 0.3s var(--ease-smooth),
        transform 0.3s var(--ease-smooth),
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        margin-bottom 0.3s var(--ease-smooth);
    will-change: background, backdrop-filter, box-shadow, opacity, transform, margin-bottom;
}

/* 初始隐藏状态 - 使用专门的类 */
.top-bar-hidden {
    opacity: 0 !important;
    transform: translateY(-20px) !important;
    pointer-events: none;
}

/* 显示状态 - 移除hidden类后的默认状态 */
.top-bar:not(.top-bar-hidden) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* 鼠标交互：自动隐藏状态 */
.top-bar.auto-hidden {
    transform: translateY(-100%);
    pointer-events: auto;
    /* Allow moving mouse back up to trigger */
    margin-bottom: calc(var(--top-bar-height) * -1);
    /* Collapse the space */
}

/* 滚动时的毛玻璃效果 */
.top-bar.scrolled {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

/* 自动隐藏状态 */
.top-bar.hidden {
    transform: translateY(-100%);
}

/* 编辑模式下，顶栏也要避让面板 */
body.editing .top-bar {
    padding-right: 310px;
    /* 280px面板 + 30px原padding */
}

/* 面板收起时，顶栏恢复 */
body.editing.panel-closed .top-bar {
    padding-right: 30px;
}

/* 滚动时添加背景 (需JS配合添加 .scrolled 类，或者始终保持样式) */
.top-bar.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.logo-img {
    height: 25px;
    /* 适应顶栏高度 */
    width: auto;
    display: block;
    opacity: 0;
    /* Anti-FOUC: loaded via JS */
    transform: scale(0.8);
    filter: blur(10px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity, filter;
}

/* Logo加载完成状态 */
.logo-img.loaded {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

/* 滚动时Logo轻微缩小（可选效果） */
.top-bar.scrolled .logo-img {
    transform: scale(0.95);
}

/* 右侧控制区 */
.controls {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    /* 为下拉菜单定位 */
}

.menu-icon,
.user-trigger {
    margin-right: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    /* Slightly more padding for clickable area */
    border-radius: 8px;
    /* Consistent rounds */
    transition: all 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    gap: 8px;
    /* Space between icon and text */
    flex-direction: row-reverse;
    /* Icon on right to match Menu Icon on left symmetry */
    will-change: transform, background;
}

.menu-icon:hover,
.user-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.05);
}

.menu-icon:active,
.user-trigger:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.08);
}

/* 菜单打开时的图标状态 */
.menu-icon.active,
.user-trigger.active {
    background: rgba(0, 122, 255, 0.1);
    color: var(--color-primary);
}

.menu-icon.active svg path,
.user-trigger.active svg path {
    fill: var(--color-primary);
}

/* 下拉菜单容器 (防止继承边框和额外间距) */
.user-dropdown-container {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 下拉菜单 */
.dropdown-menu {
    position: absolute;
    top: 100%;
    margin-top: 2px;
    /* Minimal gap for easier mouse access */
    right: 0;
    width: 220px;
    /* Wider for professional look */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-radius: 16px;
    /* Larger radius */
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    padding: 8px;
    z-index: 200;
    border: none;
    transform-origin: top right;
    animation: menuFadeIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(-10px);
        filter: blur(5px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

/* === 入场动画 (Enterprise Grade / Apple Spring) === */
@keyframes enterpriseEntrance {
    0% {
        opacity: 0;
        /* Start: Subtle offset + slight scale down */
        transform: translate3d(0, 30px, 0) scale3d(0.95, 0.95, 1);
        filter: blur(5px);
        /* Add blur for cinematic feel */
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
        filter: blur(0);
    }
}

.entry-animation {
    opacity: 0;
    /* 0.9s duration, Apple's default spring ease */
    animation: enterpriseEntrance 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    will-change: transform, opacity, filter;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}


.menu-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    margin-bottom: 2px;
    text-decoration: none;
    /* Just in case */
    opacity: 0;
    transform: translateX(-10px);
    animation: menuItemSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* 级联动画延迟 */
.menu-item:nth-child(1) {
    animation-delay: 0.05s;
}

.menu-item:nth-child(2) {
    animation-delay: 0.1s;
}

.menu-item:nth-child(3) {
    animation-delay: 0.15s;
}

.menu-item:nth-child(4) {
    animation-delay: 0.2s;
}

.menu-item:nth-child(5) {
    animation-delay: 0.25s;
}

.menu-item:nth-child(n+6) {
    animation-delay: 0.3s;
}

@keyframes menuItemSlide {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.menu-item:hover {
    background: rgba(0, 122, 255, 0.08);
    transform: translateX(4px) scale(1.02);
    /* Subtle shift + scale */
    color: var(--color-primary);
}

.menu-item:active {
    transform: translateX(4px) scale(0.98);
}

.menu-item .icon {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.2s;
    will-change: color, transform;
}

.menu-item:hover .icon {
    color: var(--color-primary);
    transform: scale(1.1);
}

/* IOS 风格按钮 */
.btn {
    padding: 8px 16px;
    border: none;
    background: white;
    box-shadow: var(--shadow-sm);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    user-select: none;
}

.btn:active {
    transform: scale(0.96);
    box-shadow: var(--shadow-inset);
}

.btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn:active:hover {
    transform: scale(0.96) translateY(0);
}

.btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn.active:hover {
    background: var(--color-primary-hover);
}

/* 毛玻璃效果工具类 */
.glass-morphism {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}


/* 主容器 (滚动区域) */
.grid-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* 防止因负边距导致的水平滚动条 */
    /* 滚动条在这里 */
    position: relative;
    width: 100%;
    /* 占满全宽，让滚动条靠边 */
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), margin 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease-out;
    opacity: 1;
}

/* 全局 loading 状态禁止滚动 (防止闪烁) */
html.loading,
body.loading {
    overflow: hidden !important;
}

body.loading .grid-container {
    opacity: 0;
    overflow: hidden;
    /* 额外保险：loading时禁止滚动 */
}

/* 内容限制区域 (居中) */
.grid-stack {
    max-width: none;
    width: 100%;
    /* 全宽 */
    margin: 0;
    /* 移除外边距 */
    padding: var(--container-padding, 10px);
    /* 最小内边距 */
    min-height: 100%;
}

/* =========================================
   编辑模式核心样式
   ========================================= */

/* Visibility utilities */
.edit-only {
    display: none !important;
}

body.editing .edit-only {
    display: flex !important;
}

body.editing .view-only {
    display: none !important;
}

/* 当进入编辑模式时，不再收缩主容器 (悬浮窗覆盖) */
body.editing .grid-container {
    width: 100%;
    margin-right: 0;
}

/* 拖拽时的模块样式 */
.grid-stack-item-content {
    background: transparent;
    padding: var(--module-padding, 0px);
    /* 透明背景 */
    border-radius: 12px;
    overflow: visible !important;
    /* 允许删除按钮显示 & 消除阴影裁剪 */
    position: relative;
    transition: z-index 0.2s;
    /* 平滑层级切换 */
}

/* 关键修复：消除阴影裁剪 & 修复下拉菜单被遮挡 */
.grid-stack-item {
    overflow: visible !important;
    transition: z-index 0.2s, transform 0.3s;
}

/* 当鼠标悬停或内部聚焦时，大幅提升层级 */
.grid-stack-item:hover {
    z-index: 100 !important;
    /* Raised for shadow visibility */
}

/* 聚焦时层级更高，确保下拉菜单不被 hover 的邻居遮挡 */
.grid-stack-item:focus-within {
    z-index: 500 !important;
}

/* 强制高层级（由 JS 动态添加，用于弹窗显示时） */
.grid-stack-item.force-high-z-index {
    z-index: 600 !important;
}

/* 编辑模式下的模块边界提示 (网格占用框) */
body.editing .grid-stack-placeholder>.placeholder-content {
    border: 1px dashed #007aff !important;
    background: rgba(0, 122, 255, 0.05) !important;
}

/* ... (unchanged) ... */

/* 切换按钮 */
.panel-toggle-btn {
    position: absolute;
    left: -40px;
    top: 50%;
    width: 40px;
    height: 60px;
    background: white;
    border-radius: 12px 0 0 12px;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9000;
    /* ALways on top */
    transition: all 0.2s;
}

/* 现有模块的网格占用示意 (使用伪元素不影响模块本身) */
body.editing .grid-stack-item::before {
    content: '';
    position: absolute;
    top: var(--grid-margin, 0);
    left: var(--grid-margin, 0);
    right: var(--grid-margin, 0);
    bottom: var(--grid-margin, 0);
    border: 1px dashed #007aff;
    background: rgba(0, 122, 255, 0.05);
    z-index: 0;
    pointer-events: none;
    border-radius: 4px;
}

/* 编辑模式下的视觉提示 */
body.editing .grid-stack {
    background: rgba(0, 0, 0, 0.02);
    border: 2px dashed #ddd;
    border-radius: 8px;
    /* 编模式下保持居中 */
}

/* 模块控制按钮组 (仅编辑模式显示) */
.module-controls {
    position: absolute;
    top: 5px;
    right: 5px;
    display: none;
    gap: 5px;
    z-index: 10;
}

body.editing .module-controls {
    display: flex;
}

.val-btn {
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.delete-btn {
    background: #ff4d4f;
    color: white;
}

.move-handle {
    background: #faad14;
    /* 橙色示人 */
    color: white;
    cursor: move;
    /* 移动光标 */
}

.settings-btn {
    background: #1890ff;
    color: white;
}

.val-btn:hover {
    transform: scale(1.1);
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    /* 调高层级，覆盖 controls */
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-box {
    background: #fff;
    width: 440px;
    max-width: 90%;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: modalPop 0.4s var(--ease-spring);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@keyframes modalPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    font-size: 24px;
    color: #999;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* 简单的表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #666;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.save-btn {
    background: #1890ff;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
}

/* 添加模块面板 */
/* 添加模块面板 - 优化版 */
/* 悬浮添加挂件 (Floating Widget) */
.floating-widget {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 9000;
    display: flex;
    flex-direction: column-reverse;
    /* Expand upwards */
    align-items: flex-end;
    gap: 15px;
    pointer-events: none;
    /* Container passes through clicks, children catch them */
}

/* 悬浮按钮 (FAB) */
.fab-trigger {
    width: 60px;
    height: 60px;
    background: #007aff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.4);
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Draggable handle */
    touch-action: none;
    user-select: none;
}

.fab-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(0, 122, 255, 0.6);
}

.fab-trigger:active {
    transform: scale(0.9);
}

/* 展开的内容面板 */
/* 展开的内容面板 - Pro Style */
.fab-panel {
    width: 320px;
    /* Slightly wider for actions */
    background: rgba(255, 255, 255, 0.4);
    /* Lower opacity for more glass feel */
    backdrop-filter: blur(40px) saturate(180%);
    /* Stronger blur */
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: 24px;
    padding: 0;
    /* Clear padding for sections */
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: auto;
    overflow: hidden;
    /* rounded corners clip */

    /* Animation */
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transform-origin: bottom right;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Springy */
    visibility: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
}

/* Smart Positioning Overrides */
.floating-widget .fab-panel.pop-down {
    bottom: auto;
    top: 80px;
    transform-origin: top right;
}

.floating-widget .fab-panel.pop-left {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.floating-widget .fab-panel.pop-down.pop-left {
    transform-origin: top left;
}

.floating-widget.active .fab-btn {
    transform: rotate(45deg);
    /* Plus becomes close X, or just rotate for style */
    background: #333;
}

.floating-widget.active .fab-panel {
    opacity: 1;
    transform: scale(1) translateY(0);
    visibility: visible;
}

/* Panel Sections */
.fab-section {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.fab-section.secondary-section {
    padding: 10px 15px;
    background: rgba(245, 245, 247, 0.8);
    /* Distinct background color */
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: none;
}

.fab-section:last-child {
    border-bottom: none;
    /* Slight contrast for bottom part */
}

.fab-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Action Grid (Settings, Save, etc) */
.action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* Mini Action Grid (Secondary) */
.action-grid-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.mini-action-btn {
    flex: 1;
    height: 36px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    gap: 6px;
    /* Space between icon and text */
}

.mini-action-btn .icon {
    font-size: 16px;
}

.mini-action-btn:hover {
    background: #fff;
    border-color: #007aff;
    color: #007aff;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.mini-action-btn.danger {
    color: #ff4d4f;
    border-color: rgba(255, 77, 79, 0.2);
}

.mini-action-btn.danger:hover {
    background: #fff1f0;
    border-color: #ff4d4f;
}

.action-btn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.action-btn-item:hover {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.action-btn-item.danger:hover {
    background: #fff1f0;
    color: #ff4d4f;
    border-color: #ffccc7;
}

.action-btn-item .icon {
    font-size: 20px;
    margin-bottom: 6px;
}

.action-btn-item span {
    font-size: 12px;
    font-weight: 500;
    color: #333;
}

.fab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.fab-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.close-fab {
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
    line-height: 1;
    color: #999;
    transition: color 0.2s;
}

.close-fab:hover {
    color: #333;
}

/* Module List (List Mode) */
.module-grid-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 2px;
    /* Scrollbar space */
}

/* Custom Scrollbar for list */
.module-grid-list::-webkit-scrollbar {
    width: 4px;
}

.module-grid-list::-webkit-scrollbar-track {
    background: transparent;
}

.module-grid-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

/* ... Module Card styles adapted for pro look ... */
.module-card {
    background: white;
    border-radius: 10px;
    padding: 10px 15px;
    display: flex;
    flex-direction: row;
    /* Horizontal layout */
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.module-card:hover {
    border-color: #007aff;
    background: #f0f7ff;
    transform: translateX(2px);
    /* Slight shift right */
}

.module-card .m-icon {
    font-size: 20px;
    margin-bottom: 0;
    width: 24px;
    text-align: center;
}

.module-card span {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    text-align: left;
}



.module-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    /* 避免滚动条贴边 */
    margin-right: -5px;
}

.add-panel h3 {
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 20px;
    color: #1d1d1f;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 15px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* 编辑模式时，面板显示 */
body.editing .add-panel {
    right: 0;
    transform: translateX(0);
}

/* 面板收缩状态 */
body.editing.panel-closed .add-panel {
    transform: translateX(300px);
}

/* 面板收缩时，主容器恢复全宽 */
body.editing.panel-closed .grid-container {
    width: 100%;
    margin-right: 0;
}

/* 切换按钮 */
.panel-toggle-btn {
    position: absolute;
    left: -40px;
    top: 50%;
    width: 40px;
    height: 60px;
    background: white;
    border-radius: 12px 0 0 12px;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 91;
    transition: all 0.2s;
}

.panel-toggle-btn:hover {
    width: 48px;
    left: -48px;
}

/* 编辑模式下显示切换按钮 */
body.editing .panel-toggle-btn {
    display: flex;
}

.module-item {
    padding: 16px;
    margin-bottom: 16px;
    background: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.module-item:hover {
    background: white;
    box-shadow: var(--shadow-md);
    transform: translateY(-4px) scale(1.02);
}

.module-item:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

/* === 选中状态 === */
.grid-stack-item.ui-selected .grid-stack-item-content {
    box-shadow: 0 0 0 2px #d32f2f, 0 4px 12px rgba(211, 47, 47, 0.3) !important;
    z-index: 100;
}

/* === 对齐工具栏 === */
.alignment-toolbar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2000;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.alignment-toolbar .tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    font-family: monospace;
    font-weight: bold;
    color: #555;
    transition: all 0.2s;
    user-select: none;
}

.alignment-toolbar .tool-btn:hover {
    background: #f0f0f0;
    color: #d32f2f;
}

.alignment-toolbar .divider {
    width: 1px;
    height: 20px;
    background: #e0e0e0;
    margin: 0 5px;
}

/* === 编辑模式网格背景 === */
body.editing .grid-stack {
    background-size: calc(100% / 24) 100%;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    /* 垂直辅助线效果 */
}

/* Removed Duplicate Login Box Styles */

/* User Widget Dropdown */
.user-dropdown-container {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.user-dropdown-container:hover {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: #007aff;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

/* =========================================
   Login Box Styles (Ultimate Unified iOS Glass)
   ========================================= */
.login-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 380px;
    padding: 48px 40px;

    /* 核心玻璃质感 - 高级感关键 */
    /* 核心玻璃质感 - 高级感关键 */
    background: #ffffff;
    /* Pure white as requested */
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    /* Strong shadow for pop */
    border-radius: 20px;
    backdrop-filter: none;
    /* Disable glass for box itself if user wants "not gray" */
    -webkit-backdrop-filter: none;

    border-radius: 28px;
    /* 混合阴影：内发光 + 柔和投影 */
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 0 20px rgba(255, 255, 255, 0.2);

    z-index: 99999;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.4);
    animation: loginSpring 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    display: flex;
    flex-direction: column;
}

@keyframes loginSpring {
    0% {
        transform: translate(-50%, -40%) scale(0.9);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.login-box h3 {
    margin-top: 0;
    margin-bottom: 36px;
    font-size: 22px;
    color: #1d1d1f;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.login-box input {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    height: 48px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 14px;
    /* 更大的圆角 */
    box-sizing: border-box;
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
    background: rgba(0, 0, 0, 0.05);
    /* 浅灰填色 */
    color: #1d1d1f;
    font-weight: 500;
}

.login-box input:focus {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: scale(1.02);
}

.login-box button,
.login-box .btn-primary {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 14px;
    background: #007AFF;
    background-image: linear-gradient(135deg, #007AFF 0%, #0056b3 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 16px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.3);
}

.login-box button:hover,
.login-box .btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.4);
    filter: brightness(1.1);
}

.login-box button:active,
.login-box .btn-primary:active {
    transform: scale(0.96);
}

/* === Unified Settings Modal (Premium Glassmorphism & Minimalist) === */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    /* Slightly darker backdrop for better focus */
    backdrop-filter: blur(8px);
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

.settings-box {
    width: 640px;
    /* Slightly wider */
    max-width: 90%;
    max-height: 85vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 24px;
    box-shadow:
        0 25px 40px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    /* Inner light border */
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    animation: popIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Dark mode adaptation */
@media (prefers-color-scheme: dark) {
    .settings-box {
        background: rgba(28, 28, 30, 0.85);
        /* Apple-like Dark Gray */
        box-shadow:
            0 25px 40px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.1) inset;
        color: white;
    }
}

.settings-header {
    padding: 24px 32px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.close-settings {
    cursor: pointer;
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    transition: 0.2s;
    color: var(--text-secondary);
}

.close-settings:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
}

/* Tabs */
.modal-tabs {
    display: flex;
    padding: 0 32px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    gap: 30px;
}

.tab-item {
    padding: 16px 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    transition: 0.2s;
}

.tab-item:hover {
    color: var(--text-primary);
}

.tab-item.active {
    color: var(--color-primary);
    font-weight: 600;
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px;
}

/* Content */
.settings-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

.settings-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.settings-tab-content.active {
    display: block;
}

/* Form Elements */
.form-section {
    margin-bottom: 30px;
}

.form-section h4 {
    margin: 0 0 16px 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
    /* Handled by grid gap usually */
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    /* More comfortable padding */
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Subtle border for white bg */
    background: #FFFFFF;
    font-size: 14px;
    color: var(--text-primary);
    transition: 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

@media (prefers-color-scheme: dark) {

    .form-input,
    .form-select {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }
}

.form-input:focus,
.form-select:focus {
    background: #fff;
    box-shadow: 0 0 0 2px var(--color-primary), 0 4px 12px rgba(0, 0, 0, 0.05);
}

.settings-footer {
    padding: 20px 32px;
    background: rgba(255, 255, 255, 0.3);
    /* Subtle separation */
    backdrop-filter: blur(10px);
    /* Extra safety for glass overlapping content */
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.save-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.2);
}

.save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(0, 122, 255, 0.3);
}

.save-btn:active {
    transform: scale(0.97);
}

@keyframes popIn {
    0% {
        transform: scale(0.95) translateY(10px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* === Toggle Switch (iOS Style) === */
.form-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    min-height: 24px;
}

.form-switch input {
    display: none;
}

.form-switch .toggle-track {
    width: 42px;
    height: 24px;
    background: #E5E5EA;
    /* Standard iOS off color */
    border-radius: 12px;
    position: relative;
    transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.form-switch .toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.form-switch input:checked+.toggle-track {
    background: var(--color-primary);
}

.form-switch input:checked+.toggle-track::after {
    transform: translateX(18px);
    /* 42 - 20 - 2 - 2 = 18 */
}

/* 桌面分页指示器 */
.desktop-pagination {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 8000;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s var(--ease-smooth);
    touch-action: none;
    /* Prevent browser handling, enable JS tracking */
}

.desktop-pagination:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Pagination Customizations */
/* Pagination Customizations */
.desktop-pagination.left,
.desktop-pagination.right {
    flex-direction: column !important;
    /* Force vertical stacking */
    left: auto;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    /* Center vertical, NO Horizontal Translate */
    padding: 16px 8px;
    /* Vertical padding */
    width: auto;
    height: auto;
}

.desktop-pagination.left {
    left: 20px;
}

.desktop-pagination.right {
    right: 20px;
}

/* Hover Scale Effect for Visible Vertical */
/* Only apply scale when NOT hidden mode */
.desktop-pagination.left:not(.hover-2s):hover,
.desktop-pagination.right:not(.hover-2s):hover {
    transform: translateY(-50%) scale(1.05);
}

/* Visibility Modes */
.desktop-pagination.hidden {
    display: none !important;
}

/* Hover-2s Base (Bottom Default) */
.desktop-pagination.hover-2s {
    opacity: 0;
    /* Move down 20px from default position (translateX -50%) */
    transform: translateX(-50%) translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition-delay: 0s;
}

/* Expand hit area */
.desktop-pagination.hover-2s::after {
    content: '';
    position: absolute;
    top: -30px;
    bottom: -30px;
    left: -30px;
    right: -30px;
    /* Generous hit area */
    z-index: -1;
}

.desktop-pagination.hover-2s:hover {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    /* Restore to default center */
    transition-delay: 0.5s;
}

/* Vertical + Hover-2s Combination */
/* LEFT Side Hidden */
.desktop-pagination.left.hover-2s {
    /* Hidden state: moved left 20px, Vertically centered */
    transform: translateY(-50%) translateX(-20px) !important;
}

/* LEFT Side Shown */
.desktop-pagination.left.hover-2s:hover {
    transform: translateY(-50%) translateX(0) !important;
}

/* RIGHT Side Hidden */
.desktop-pagination.right.hover-2s {
    /* Hidden state: moved right 20px, Vertically centered */
    transform: translateY(-50%) translateX(20px) !important;
}

/* RIGHT Side Shown */
.desktop-pagination.right.hover-2s:hover {
    transform: translateY(-50%) translateX(0) !important;
}


.page-dot {
    position: relative;
    /* Anchor for absolute children */
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.page-dot:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.2);
}

.page-dot.active {
    width: 24px;
    background: var(--color-primary);
    border-radius: 4px;
}

/* Fix Active Dot for Vertical Layout */
.desktop-pagination.left .page-dot.active,
.desktop-pagination.right .page-dot.active {
    width: 8px;
    height: 24px;
}

/* === Delete Page Button (Inside Active Dot) === */
.page-dot .delete-icon {
    position: absolute;
    width: 14px;
    height: 14px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: #ff4d4f;
    /* Red background by default for visibility */
    z-index: 10;
}

.page-dot .delete-icon svg {
    width: 8px;
    height: 8px;
}

.page-dot .delete-icon:hover {
    background: #ff7875;
    transform: scale(1.1) !important;
}

/* === Global Visibility in Edit Mode === */
/* All Dots: Expanded Pill Style */
body.editing .page-dot {
    width: 36px;
    /* Expanded Width (Compact 36px is enough for icon) */
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    /* Slightly darken for visibility */
}

/* Specific background for active remains */
body.editing .page-dot.active {
    width: 48px;
    /* Active can be wider or same */
    background: var(--color-primary);
}

body.editing .page-dot .delete-icon {
    right: 2px;
    top: 50%;
    transform: translateY(-50%) scale(0.9);
    opacity: 1;
    pointer-events: auto;
}

/* Vertical Layout Adjustments */
/* Edit Mode + Vertical + All Dots */
body.editing .desktop-pagination.left .page-dot,
body.editing .desktop-pagination.right .page-dot {
    width: 8px;
    height: 36px;
}

body.editing .desktop-pagination.left .page-dot.active,
body.editing .desktop-pagination.right .page-dot.active {
    height: 48px;
}

body.editing .desktop-pagination.left .page-dot .delete-icon,
body.editing .desktop-pagination.right .page-dot .delete-icon {
    right: auto;
    top: auto;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
}

/* 页面切换动画过渡 */
.grid-container {
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.3s ease;
}

/* === Auto-Hide Topbar Logic === */
body.auto-hide-topbar .top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    transform: translateY(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

body.auto-hide-topbar .top-bar:hover,
body.top-bar-visible .top-bar {
    transform: translateY(0) !important;
}

/* content push animation */
body.auto-hide-topbar .grid-container {
    transition: margin-top 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    margin-top: 0 !important;
    /* Reclaim space when hidden */
}

body.auto-hide-topbar.top-bar-visible .grid-container {
    margin-top: var(--top-bar-height) !important;
    /* Push down when shown */
}

/* Adjust top-bar styling when fixed to prevent transparency issues if desired */
body.auto-hide-topbar .top-bar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}