/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    background: #f5f5f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 画布容器 ==================== */
#canvas-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background: 
        linear-gradient(90deg, rgba(200,200,200,0.1) 1px, transparent 1px),
        linear-gradient(rgba(200,200,200,0.1) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: 0 0;
}

#canvas-container.dragging {
    cursor: grabbing;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* ==================== 笔记卡片 ==================== */
.note-card {
    position: absolute;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 12px;
    cursor: default;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.3s;
    border: 2px solid transparent;
    z-index: 10;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.note-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transform: translateY(-2px);
}

/* ==================== 笔记高亮样式系统 ==================== */
/* 1️⃣ 状态高亮 - 使用中央背景水印图标+边框 */
.note-card[data-status]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    opacity: 0.15;
    pointer-events: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 0;
}

.note-card[data-status="published"]::after {
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 170.666667a341.333333 341.333333 0 0 0-290.133333 521.216 42.666667 42.666667 0 0 1-72.533334 45.013333A424.874667 424.874667 0 0 1 85.333333 512C85.333333 276.352 276.352 85.333333 512 85.333333s426.666667 191.018667 426.666667 426.666667-191.018667 426.666667-426.666667 426.666667a424.874667 424.874667 0 0 1-234.666667-70.314667 42.666667 42.666667 0 1 1 46.933334-71.210667A341.333333 341.333333 0 1 0 512 170.666667z m222.165333 264.832a42.666667 42.666667 0 0 0-60.330666-60.330667L469.333333 579.669333l-119.168-119.168a42.666667 42.666667 0 0 0-60.330666 60.330667l149.333333 149.333333a42.666667 42.666667 0 0 0 60.330667 0l234.666666-234.666666z" fill="%234CAF50"/></svg>');
}

.note-card[data-status="unpublished"]::after {
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 256C476.8 256 448 284.8 448 320l0 192c0 35.2 28.8 64 64 64s64-28.8 64-64L576 320C576 284.8 547.2 256 512 256zM512 64C264.32 64 64 264.32 64 512s200.32 448 448 448 448-200.32 448-448S759.04 64 512 64zM512 896c-211.84 0-384-172.16-384-384s172.16-384 384-384 384 172.16 384 384S723.84 896 512 896zM512 640c-35.2 0-64 28.8-64 64s28.8 64 64 64 64-28.8 64-64S547.2 640 512 640z" fill="%23FF9800"/></svg>');
}

.note-card[data-status="archived"]::after {
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M874.338462 149.661538C779.815385 55.138462 645.907692 0 512 0S244.184615 55.138462 149.661538 149.661538C55.138462 244.184615 0 378.092308 0 512s55.138462 267.815385 149.661538 362.338462S378.092308 1024 512 1024s267.815385-55.138462 362.338462-149.661538S1024 645.907692 1024 512s-55.138462-267.815385-149.661538-362.338462zM512 945.230769C275.692308 945.230769 78.769231 748.307692 78.769231 512S275.692308 78.769231 512 78.769231 945.230769 275.692308 945.230769 512 748.307692 945.230769 512 945.230769zM425.353846 370.215385c-15.753846-15.753846-39.384615-15.753846-55.138461 0s-15.753846 39.384615 0 55.138461l220.553846 220.553846c15.753846 15.753846 39.384615 15.753846 55.138461 0s15.753846-39.384615 0-55.138461L425.353846 370.215385z" fill="%239E9E9E"/></svg>');
}

.note-card[data-status="archived"] {
    opacity: 0.75;
}

.note-card[data-status="published"] {
    border: 1px solid #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.25);
}

.note-card[data-status="unpublished"] {
    border: 1px solid #FF9800;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.25);
}

.note-card[data-status="archived"] {
    border: 1px solid #9E9E9E;
    box-shadow: 0 2px 8px rgba(158, 158, 158, 0.25);
    opacity: 0.75;
}

/* 2️⃣ 选中状态 - 使用紫色虚线 outline，有间隔 */
.note-card.selected {
    outline: 2px dashed #2196F3;
    outline-offset: 4px;
}

/* 3️⃣ 组内高亮 - 使用组颜色的边框 */
.note-card.in-group {
    --group-color-rgb: 48, 227, 202; /* 默认颜色（如果没有设置组颜色）*/
    border: 1px solid rgba(var(--group-color-rgb), 0.5);
    box-shadow: 0 2px 8px rgba(var(--group-color-rgb), 0.2);
}

.note-card.dragging {
    cursor: grabbing;
    opacity: 0.8;
    z-index: 100;
}

/* 笔记头部 */
.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    cursor: move;
    flex-shrink: 0;  /* 头部不收缩 */
    position: relative;
    z-index: 1;
}

.note-date {
    font-size: 12px;
    color: #999;
}

/* 头部右侧操作区域 */
.note-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 菜单按钮 */
.note-menu-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    color: #666;
    flex-shrink: 0;
}

.note-menu-btn:hover {
    background: #f5f5f5;
}

.note-menu-btn.active {
    background: #e3f2fd;
    color: #2196F3;
}

/* 横向弹出菜单 - 显示在卡片上方 */
.note-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);  /* 显示在卡片上方 */
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 6px;
    z-index: 1000;
    display: none;
    animation: menuSlideUp 0.2s ease-out;
    min-width: 360px;
}

.note-dropdown-menu.show {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

@keyframes menuSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 状态选项 */
.note-status-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 13px;
    color: #333;
    gap: 6px;
    white-space: nowrap;
}

.note-status-option:hover {
    background: #f5f5f5;
}

.note-status-option.active {
    background: #e3f2fd;
    color: #2196F3;
}

.note-status-option .status-icon {
    font-size: 14px;
    width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-status-option .status-label {
    font-size: 12px;
}

/* 菜单分割线 */
.note-menu-divider {
    width: 1px;
    height: 24px;
    background: #e0e0e0;
    margin: 0 4px;
}

/* 删除按钮 */
.note-delete-btn {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 13px;
    color: #f44336;
    gap: 6px;
    white-space: nowrap;
}

.note-delete-btn:hover {
    background: #ffebee;
}

.note-delete-btn .delete-icon {
    font-size: 14px;
}

/* 笔记标题 */
.note-title {
    width: 100%;
    flex-shrink: 0;  /* 标题不收缩 */
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
    font-family: inherit;
    background: transparent;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    position: relative;
    z-index: 1;
}

.note-title::placeholder {
    color: #ccc;
    font-weight: normal;
}

/* 笔记内容 */
.note-content {
    width: 100%;
    flex: 1 1 auto;
    min-height: 50px;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    background: transparent;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

/* 隐藏 textarea 默认的调整大小手柄（已有整体卡片调整手柄） */
.note-content::-webkit-resizer {
    display: none;
}

.note-content::placeholder {
    color: #ccc;
}

/* ==================== 连接按钮 ==================== */
.connect-handle {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.connect-handle svg {
    display: block;
    flex-shrink: 0;
}

.note-card:hover .connect-handle {
    opacity: 1;
    right: -14px;
}

.connect-handle:hover {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
    transform: translateY(-50%) scale(1.2);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.6);
}

.connect-handle:active {
    transform: translateY(-50%) scale(0.95);
}

.connect-handle.dragging {
    opacity: 1;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

/* 连接数量徽章 */
.connection-badge {
    min-width: 24px;
    height: 24px;
    background: #e0e0e0;
    border: 2px solid white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: normal;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    pointer-events: none;
    box-shadow: none;
    opacity: 0.5;
    white-space: nowrap;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

/* 有连接时：蓝色渐变、明显、有阴影 */
.connection-badge.has-connections {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    opacity: 1;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
    animation: badgePulse 0.5s ease-out;
}

@keyframes badgePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* 笔记底部 */
.note-footer {
    padding: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.05) 0%, rgba(139, 195, 74, 0.05) 100%);
    display: flex;
    align-items: center;
    min-height: 42px;
    position: relative;
    overflow: hidden;
    margin-top: 8px;
    flex-shrink: 0;  /* 防止被压缩 */
    z-index: 1;
}

@keyframes reminderPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
    }
    50% {
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.8);
    }
}

.note-reminder {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    padding: 10px 12px;
    transition: all 0.3s;
    position: relative;
    min-width: 0;  /* 允许收缩 */
    overflow: hidden;  /* 隐藏溢出内容 */
}

.reminder-label {
    font-size: 13px;
    color: #4CAF50;
    font-weight: 600;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    padding-left: 16px;
    white-space: nowrap;  /* 不换行 */
    flex-shrink: 1;  /* 允许收缩 */
    min-width: 0;  /* 允许收缩到0 */
}

/* 圆点指示器（始终显示在文字前面） */
.reminder-label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    transition: all 0.3s;
    flex-shrink: 0;
}

/* 有提醒日期时显示绿点并添加脉冲动画 */
.note-footer.has-reminder .reminder-label::before {
    background: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
    animation: reminderPulse 2s infinite;
}


.reminder-date-input {
    padding: 5px 8px;
    border: 1.5px solid #4CAF50;
    border-radius: 6px;
    font-size: 13px;
    color: #2c6e2f;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    flex-shrink: 0;  /* 日期输入框不收缩 */
    min-width: 110px;  /* 最小宽度能显示完整日期 */
}

.reminder-date-input:hover {
    border-color: #45a049;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
    transform: translateY(-1px);
}

.reminder-date-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

/* 有值时的高亮样式 */
.reminder-date-input:not([value=""]) {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.08) 0%, rgba(139, 195, 74, 0.08) 100%);
    border-color: #4CAF50;
    color: #2c6e2f;
}

/* 使用容器查询（同时监听宽度和高度） */
.note-card {
    container-type: size;
    container-name: note-card;
}

/* 当笔记卡片宽度小于240px时，隐藏日期选择区域，只显示小圆点 */
@container note-card (max-width: 240px) {
    .note-reminder {
        display: none;
    }
    
    .note-footer {
        min-height: 20px;
        background: transparent;
        margin-top: 6px;
        overflow: hidden;  /* 防止溢出 */
    }
    
    /* 调整内容区域的最小高度 */
    .note-content {
        min-height: 40px;
        overflow-x: hidden;  /* 防止水平溢出 */
        word-wrap: break-word;  /* 强制换行 */
    }
    
    /* 调整标题 */
    .note-title {
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* 调整下拉菜单的最小宽度，防止溢出 */
    .note-dropdown-menu {
        min-width: 200px;
    }
    
    /* 在左下角显示圆点 */
    .note-footer::after {
        content: '';
        position: absolute;
        left: 12px;
        bottom: 4px;
        width: 8px;
        height: 8px;
        background: #ccc;
        border-radius: 50%;
        transition: all 0.3s;
        pointer-events: none;
    }
    
    .note-footer.has-reminder::after {
        background: #4CAF50;
        box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
        animation: reminderPulse 2s infinite;
    }
}

@container note-card (max-height: 160px) {
    .note-reminder {
        display: none;
    }
    
    .note-footer {
        min-height: 20px;
        background: transparent;
        margin-top: 6px;
        overflow: hidden;  /* 防止溢出 */
    }
    
    /* 调整内容区域的最小高度 */
    .note-content {
        min-height: 30px;
        overflow-y: auto;  /* 允许内容滚动 */
    }
    
    /* 调整标题 */
    .note-title {
        font-size: 14px;
    }
    
    /* 调整下拉菜单的最小宽度，防止溢出 */
    .note-dropdown-menu {
        min-width: 200px;
    }
    
    /* 在左下角显示圆点 */
    .note-footer::after {
        content: '';
        position: absolute;
        left: 12px;
        bottom: 4px;
        width: 8px;
        height: 8px;
        background: #ccc;
        border-radius: 50%;
        transition: all 0.3s;
        pointer-events: none;
    }
    
    .note-footer.has-reminder::after {
        background: #4CAF50;
        box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
        animation: reminderPulse 2s infinite;
    }
}

/* 极小尺寸优化 */
@container note-card (max-height: 120px) {
    .note-content {
        min-height: 20px;
        font-size: 12px;
    }
    
    .note-title {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .note-header {
        margin-bottom: 4px;
        padding-bottom: 4px;
    }
    
    .note-footer {
        margin-top: 4px;
        min-height: 16px;
    }
    
    .note-footer::after {
        bottom: 2px;
        width: 6px;
        height: 6px;
    }
}

/* 调整大小手柄 */
.resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 40;
}

.resize-handle::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, transparent 0%, transparent 40%, #999 40%, #999 45%, transparent 45%, transparent 55%, #999 55%, #999 60%, transparent 60%);
    border-radius: 0 0 6px 0;
}

.note-card:hover .resize-handle {
    opacity: 1;
}

.resize-handle:hover::after {
    background: linear-gradient(135deg, transparent 0%, transparent 40%, #2196F3 40%, #2196F3 45%, transparent 45%, transparent 55%, #2196F3 55%, #2196F3 60%, transparent 60%);
}

/* ==================== SVG 连线 ==================== */
/* 可见层 - 在卡片下面 */
#connections-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1; /* 在画布下面，视觉效果正确 */
    pointer-events: none;
}

/* 交互层 - 在卡片上面，用于接收鼠标事件 */
#connections-interaction-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100; /* 在所有内容上面，确保能响应事件 */
    pointer-events: none; /* SVG本身不响应 */
}

/* 连线组 */
.connection-group {
    pointer-events: none;
}

/* 连线路径 */
.connection-path {
    fill: none;
    stroke: #2196F3;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    transition: stroke 0.2s, stroke-width 0.2s;
}

/* 悬停时连线加粗变色 */
.connection-path.hover {
    stroke: #1976D2;
    stroke-width: 3.5;
}

/* 宽透明交互路径 - 用于右键菜单 */
.connection-hit-path {
    pointer-events: stroke;
    cursor: context-menu;
    transition: stroke 0.2s;
}

/* 悬停时显示半透明提示 */
.connection-hit-path:hover {
    stroke: rgba(33, 150, 243, 0.1) !important;
}

/* 连线右键菜单 */
.connection-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 4px;
    z-index: 10000;
    min-width: 150px;
    animation: menuFadeIn 0.15s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 14px;
    gap: 8px;
    user-select: none;
}

.context-menu-item:hover {
    background: #f5f5f5;
}

.context-menu-item.delete-item {
    color: #f44336;
}

.context-menu-item.delete-item:hover {
    background: #ffebee;
}

.context-menu-item .menu-icon {
    font-size: 16px;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 临时连线（拖动时） */
.temp-connection {
    stroke: #2196F3;
    stroke-width: 2;
    stroke-dasharray: 8, 4;
    fill: none;
    pointer-events: none;
    animation: dash 0.5s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -12;
    }
}

/* ==================== 工具栏 ==================== */
#toolbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px 20px;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    gap: 12px;
    z-index: 1000;
    align-items: center;
}

.toolbar-btn {
    padding: 8px 16px;
    border: none;
    background: #4CAF50;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.toolbar-btn:active {
    transform: translateY(0);
}

.toolbar-btn.secondary {
    background: #2196F3;
}

.toolbar-btn.secondary:hover {
    background: #1976D2;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

/* 高亮状态 - 用于单独整理选中 */
.toolbar-btn.highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    animation: buttonPulse 2s ease-in-out infinite;
}

.toolbar-btn.highlight:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a4294 100%);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
}

@keyframes buttonPulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.6);
    }
}

/* 禁用状态 */
.toolbar-btn.disabled,
.toolbar-btn:disabled {
    background: #ccc;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.toolbar-btn.disabled:hover,
.toolbar-btn:disabled:hover {
    background: #ccc;
    transform: none;
    box-shadow: none;
}

.toolbar-btn.danger {
    background: #f44336;
}

.toolbar-btn.danger:hover {
    background: #d32f2f;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.toolbar-divider {
    width: 1px;
    height: 30px;
    background: #ddd;
}

/* ==================== 右侧面板容器 ==================== */
#right-sidebar {
    position: fixed;
    top: 20px;
    right: 20px;
    bottom: 20px;
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1000;
    transition: transform 0.3s ease;
}

#right-sidebar.collapsed {
    transform: translateX(calc(100% + 20px));
}

/* 侧边栏展开按钮 */
.sidebar-toggle-float-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all 0.3s ease;
    color: #666;
    opacity: 0;
    pointer-events: none;
}

#right-sidebar.collapsed ~ .sidebar-toggle-float-btn {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-toggle-float-btn:hover {
    background: #f5f5f5;
    color: #333;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transform: scale(1.05);
}

.sidebar-toggle-float-btn svg {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

/* 通用面板样式 */
.reminder-panel,
#canvas-info-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 提醒面板 - 70%高度 */
.reminder-panel {
    flex: 7;
    min-height: 0;
}

/* 画布信息面板 - 30%高度 */
#canvas-info-panel {
    flex: 2;
    min-height: 0;
}

/* 面板头部 */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
    flex-shrink: 0;
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    flex: 1;
}

/* 面板折叠按钮 */
.panel-collapse-btn {
    background: transparent;
    border: none;
    color: #666;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.panel-collapse-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.panel-collapse-btn svg {
    width: 16px;
    height: 16px;
}

/* 面板内容 */
.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    min-height: 0;
}

/* 统计信息样式 */
.stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #666;
}

.stats-item span {
    font-weight: 500;
}

.stats-item strong {
    color: #333;
    font-weight: 600;
}

.mode-info {
    font-size: 12px;
    color: #999;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 6px;
    text-align: center;
}

/* ==================== 提示信息 ==================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    z-index: 2000;
    animation: fadeInOut 2s forwards;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@keyframes fadeInOut {
    0% { 
        opacity: 0; 
        transform: translateX(-50%) translateY(20px);
    }
    10%, 90% { 
        opacity: 1; 
        transform: translateX(-50%) translateY(0);
    }
    100% { 
        opacity: 0; 
        transform: translateX(-50%) translateY(-20px);
    }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    #toolbar {
        flex-wrap: wrap;
        max-width: 90vw;
        padding: 10px;
        gap: 8px;
    }
    
    .toolbar-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    #sidebar {
        right: 10px;
        top: auto;
        bottom: 10px;
        width: calc(100vw - 20px);
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    #toolbar,
    #sidebar {
        display: none;
    }
    
    #canvas-container {
        overflow: visible;
    }
    
    .connect-handle {
        display: none;
    }
}

/* ==================== 框选框 ==================== */
.selection-box {
    position: fixed;
    border: 2px dashed #2196F3;
    background: rgba(33, 150, 243, 0.1);
    z-index: 10000;
    pointer-events: none;
    display: none;
    animation: selectionPulse 1s ease-in-out infinite;
}

@keyframes selectionPulse {
    0%, 100% {
        border-color: #2196F3;
        background: rgba(33, 150, 243, 0.1);
    }
    50% {
        border-color: #1976D2;
        background: rgba(33, 150, 243, 0.15);
    }
}

/* ==================== 高亮效果 ==================== */
.note-card.highlight {
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 4️⃣ 待连接状态 - 使用蓝绿色实线 outline，有间隔 */
.note-card.connection-target {
    outline: 2px solid #2196F3;
    outline-offset: 4px;
    box-shadow: 0 4px 16px rgb(33 150 243 / 30%), 0 0 0 8px rgb(33 150 243 / 15%);
}

/* ==================== 分组样式 ==================== */
.note-group {
    position: absolute;
    border: 2px dashed rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    background: rgba(255, 183, 77, 0.15);
    min-width: 200px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    cursor: move;
}

.note-group:hover {
    border-color: rgba(0, 0, 0, 0.4);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.note-group.dragging {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border-color: rgba(0, 0, 0, 0.5);
    cursor: move;
}

.note-group.resizing {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}


/* 分组头部 */
.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px 10px 0 0;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    flex-shrink: 0;
    gap:10px;
}

.group-header:hover {
    background: rgba(255, 255, 255, 0.7);
}

/* 分组标题 */
.group-title {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    outline: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-title:hover {
    background: rgba(255, 255, 255, 0.8);
}

.group-title:focus {
    background: white;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}

/* 分组操作按钮 */
.group-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0; /* 防止按钮组被压缩 */
}

.group-delete-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.8);
    color: #666;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.group-delete-btn:hover {
    background: #f44336;
    color: white;
    transform: scale(1.1);
}

/* 分组内容区域 */
.group-content {
    flex: 1;
    padding: 12px;
    position: relative;
    overflow: hidden;
    min-height: 80px;
}

/* 分组占位符 */
.group-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 0, 0, 0.3);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 分组调整大小手柄 */
.group-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 0%, transparent 50%, rgba(0, 0, 0, 0.2) 50%, rgba(0, 0, 0, 0.2) 100%);
    border-radius: 0 0 10px 0;
}

.group-resize-handle:hover {
    background: linear-gradient(135deg, transparent 0%, transparent 50%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.4) 100%);
}

/* 分组拖动提示 */
.note-group::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 10px;
    pointer-events: none;
}

.note-group.dragging::before {
    background: rgba(33, 150, 243, 0.1);
}

/* 分组高亮（拖动笔记悬停时） */
.note-group.drop-target {
    border-color: #2196F3;
    border-width: 3px;
    border-style: solid;
    background: rgba(33, 150, 243, 0.2);
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.3);
    animation: groupPulse 1s infinite;
}

@keyframes groupPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* 笔记加入分组动画 */
.note-card.group-join-animation {
    animation: joinGroup 0.6s ease-out;
}

@keyframes joinGroup {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 8px 24px rgba(33, 150, 243, 0.4), 0 0 0 4px rgba(33, 150, 243, 0.5);
    }
    100% {
        transform: scale(1);
    }
}

/* 分组删除菜单 */
.group-delete-menu {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 4px;
    z-index: 10000;
    min-width: 200px;
    animation: menuSlideUp 0.2s ease-out;
}

.delete-menu-item {
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #333;
}

.delete-menu-item:hover {
    background: #f5f5f5;
}

.delete-menu-item.danger {
    color: #f44336;
}

.delete-menu-item.danger:hover {
    background: #ffebee;
}

/* ==================== 提醒列表 ==================== */
.reminder-empty {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* 提醒项 */
.reminder-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.reminder-item:hover {
    border-color: #2196F3;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.1);
    transform: translateX(-2px);
}

.reminder-item:last-child {
    margin-bottom: 0;
}

/* 复选框 */
.reminder-checkbox {
    flex-shrink: 0;
    margin-top: 2px;
}

.reminder-checkbox input[type="checkbox"] {
    display: none;
}

.reminder-checkbox label {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.reminder-checkbox label:hover {
    border-color: #2196F3;
}

.reminder-checkbox input[type="checkbox"]:checked + label {
    background: #4CAF50;
    border-color: #4CAF50;
}

.reminder-checkbox input[type="checkbox"]:checked + label::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

/* 提醒信息 */
.reminder-info {
    flex: 1;
    min-width: 0;
}

.reminder-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reminder-preview {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reminder-date {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reminder-date.overdue {
    color: #f44336;
    font-weight: 600;
}

.reminder-date.today {
    color: #ff9800;
    font-weight: 600;
}

.reminder-date.soon {
    color: #2196F3;
}

.reminder-date.future {
    color: #999;
}

.reminder-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
}

.reminder-date.overdue .reminder-status {
    background: #ffebee;
    color: #f44336;
}

.reminder-date.today .reminder-status {
    background: #fff3e0;
    color: #ff9800;
}

.reminder-date.soon .reminder-status {
    background: #e3f2fd;
    color: #2196F3;
}


/* 笔记高亮动画 */
.note-card.highlight {
    animation: highlightPulse 1s ease-in-out 2;
}

@keyframes highlightPulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 193, 7, 0.4), 0 8px 32px rgba(255, 193, 7, 0.3);
        transform: scale(1.05);
    }
}

/* 滚动条样式 */
.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.panel-content::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}