﻿/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface2: #e8ecf1;
    --text: #1a2332;
    --text-secondary: #7f8c9b;
    --primary: #e94560;
    --primary-hover: #ff6b81;
    --primary-light: rgba(233, 69, 96, 0.12);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --note-text-color: #2c3e50;
    --toolbar-bg: rgba(255, 255, 255, 0.88);
    --toolbar-border: rgba(0, 0, 0, 0.06);
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --toast-bg: #ffffff;
    --toast-text: #1a2332;
    --toast-shadow: 0 6px 28px rgba(0, 0, 0, 0.15);
}

/* 深色模式 */
[data-theme="dark"] {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface2: #243447;
    --text: #e1e8ed;
    --text-secondary: #8899a6;
    --primary: #ff6b81;
    --primary-hover: #ff8fa3;
    --primary-light: rgba(255, 107, 129, 0.15);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    /* 便利贴文字保持深色——因为便利贴底色是用户选的亮色 */
    --note-text-color: #2c3e50;
    --toolbar-bg: rgba(15, 20, 25, 0.88);
    --toolbar-border: rgba(255, 255, 255, 0.06);
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --toast-bg: #2a3a4a;
    --toast-text: #e1e8ed;
    --toast-shadow: 0 6px 28px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'FangSong', '仿宋', STFangsong, serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    transition: background 0.35s ease, color 0.35s ease;
}

/* ===== 工具栏 ===== */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    background: var(--toolbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--toolbar-border);
    flex-wrap: wrap;
    gap: 12px;
    transition: background 0.35s ease;
}

.toolbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Logo 轻柔微动动画 */
@keyframes logoBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

.toolbar-title .logo {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    display: inline-block;
    animation: logoBounce 3s ease-in-out infinite;
    cursor: default;
}

.toolbar-title .logo:hover {
    animation: logoBounce 0.8s ease-in-out infinite;
}

/* 标题渐变流动动画 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.toolbar-title h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #e94560 0%, #c0392b 25%, #0f3460 50%, #c0392b 75%, #e94560 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease-in-out infinite;
}

/* 暗色模式：调亮渐变末段，避免深蓝融进暗色背景 */
[data-theme="dark"] .toolbar-title h1 {
    background: linear-gradient(135deg, #ff6b81 0%, #e94560 25%, #7eb8da 50%, #e94560 75%, #ff6b81 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease-in-out infinite;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
}

.note-count {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 20px;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    font-family: inherit;
    letter-spacing: 0.3px;
}

/* 按钮光晕呼吸动画 */
@keyframes btnGlow {
    0%, 100% {
        box-shadow: 0 4px 14px rgba(233, 69, 96, 0.3);
    }
    50% {
        box-shadow: 0 4px 24px rgba(233, 69, 96, 0.5), 0 0 40px rgba(233, 69, 96, 0.1);
    }
}

.btn-add {
    background: linear-gradient(135deg, var(--primary), #d63851);
    color: #fff;
    box-shadow: 0 4px 14px rgba(233, 69, 96, 0.3);
    animation: btnGlow 2.5s ease-in-out infinite;
}

.btn-add:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(233, 69, 96, 0.4);
    animation: btnGlow 1.2s ease-in-out infinite;
}

.btn-add:active {
    transform: translateY(0);
}

.btn-clear {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-clear:hover {
    background: rgba(233, 69, 96, 0.1);
    color: var(--primary);
    border-color: rgba(233, 69, 96, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #d63851);
    color: #fff;
    padding: 10px 28px;
    font-size: 15px;
    box-shadow: 0 4px 14px rgba(233, 69, 96, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.35);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
    padding: 10px 28px;
    font-size: 15px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background: linear-gradient(135deg, #e94560, #c0392b);
    color: #fff;
    padding: 10px 28px;
    font-size: 15px;
    box-shadow: 0 4px 14px rgba(233, 69, 96, 0.25);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ff6b81, #e94560);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.35);
}

/* 画板光晕流动动画 */
@keyframes boardGlowShift {
    0%, 100% {
        background-position: 20% 50%, 80% 50%, 0 0;
    }
    50% {
        background-position: 25% 48%, 75% 52%, 0 0;
    }
}

/* ===== 画板 ===== */
.board {
    height: 100vh;
    padding: 90px 32px 40px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 24px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(233, 69, 96, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(15, 52, 96, 0.03) 0%, transparent 50%),
        radial-gradient(circle, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 24px 24px;
    animation: boardGlowShift 8s ease-in-out infinite;
}

/* ===== 便利贴 ===== */
.note {
    width: 260px;
    max-height: 300px;
    padding: 22px 22px 42px;
    border-radius: 14px;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06),
        0 4px 20px rgba(0, 0, 0, 0.06);
    cursor: grab;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, opacity 0.25s ease;
    display: flex;
    flex-direction: column;
    word-break: break-word;
    user-select: none;
    -webkit-user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    /* 静止时零 transform → 文字锐利 */
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
}

/* 便利贴顶部折角效果 */
.note::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, transparent 50%, var(--fold-color, rgba(0, 0, 0, 0.05)) 50%);
    border-radius: 0 14px 0 0;
    pointer-events: none;
}

/* 便利贴底部阴影（模拟粘贴效果） */
.note::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 8px;
    right: 8px;
    height: 8px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

@keyframes noteAppear {
    0% {
        opacity: 0;
        transform: scale(0.85) rotate(-3deg) translateY(16px);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg) translateY(0);
    }
}

/* 便利贴持续微浮动动画（柔和正弦波，几乎不可察觉） */
@keyframes noteFloat {
    0%, 100% {
        transform: translateY(0) rotate(var(--rot, 0deg));
    }
    50% {
        transform: translateY(-3px) rotate(var(--rot, 0deg));
    }
}

/* 便利贴阴影呼吸动画 */
@keyframes noteShadowBreathe {
    0%, 100% {
        box-shadow:
            0 2px 8px rgba(0, 0, 0, 0.06),
            0 4px 20px rgba(0, 0, 0, 0.06);
    }
    50% {
        box-shadow:
            0 4px 14px rgba(0, 0, 0, 0.09),
            0 8px 28px rgba(0, 0, 0, 0.1);
    }
}

/* 入场动画（仅首次创建时播放一次，拖拽结束后不会重播） */
.note-appear {
    animation: noteAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.note {
    animation:
        noteFloat 4s ease-in-out var(--float-delay, 0s) infinite,
        noteShadowBreathe 3s ease-in-out var(--shadow-delay, 0s) infinite;
}

.note:hover {
    transform: translateY(-6px) scale(1.02) rotate(var(--rot, 0deg));
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.1),
        0 16px 48px rgba(0, 0, 0, 0.08);
    will-change: transform;
}

.note:active {
    cursor: grabbing;
}

.note.dragging {
    opacity: 0.92;
    animation: none;
    /* 【核心修复】仅在拖拽时开启 translateZ(0) 3D 加速，滑动时丝滑，松手后立刻恢复文字最高清晰度 */
    transform: scale(1.05) rotate(calc(var(--rot, 0deg) + 1.5deg)) translateZ(0);
    z-index: 99999 !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
    transition: box-shadow 0.15s ease;
    will-change: transform, left, top;
    pointer-events: none;
}

.note .note-text {
    font-size: 20px;
    line-height: 1.75;
    color: var(--text-color, #2c3e50);
    white-space: pre-wrap;
    word-wrap: break-word;
    cursor: text;
    padding: 2px 0;
    min-height: 1.2em;
    user-select: text;
    -webkit-user-select: text;
    overflow-y: auto;
    flex: 1 1 auto;
    padding-right: 4px; /* 滚动条空间预留 */
}

/* ===== 全局文字选中样式 ===== */
::selection {
    background: rgba(0, 0, 0, 0.15);
    color: inherit;
}

::-moz-selection {
    background: rgba(0, 0, 0, 0.15);
    color: inherit;
}

/* 深色模式全局选中 */
[data-theme="dark"] ::selection {
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
}

[data-theme="dark"] ::-moz-selection {
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
}

/* 便利贴内选中 */
.note .note-text::selection {
    background: rgba(0, 0, 0, 0.18);
    color: inherit;
}

.note .note-text::-moz-selection {
    background: rgba(0, 0, 0, 0.18);
    color: inherit;
}

/* 深色底便利贴 → 浅色选中 */
.note[data-sb-theme="light"] .note-text::selection {
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
}

.note[data-sb-theme="light"] .note-text::-moz-selection {
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
}

/* 便利贴内文本滚动条 */
.note .note-text::-webkit-scrollbar {
    width: 6px;
}

.note .note-text::-webkit-scrollbar-track {
    background: transparent;
}

/* 浅色底 → 深色滚动条 */
.note[data-sb-theme="dark"] .note-text::-webkit-scrollbar-thumb {
    --sb-opacity: 0.15;
    background: rgba(0, 0, 0, var(--sb-opacity));
    border-radius: 3px;
    transition: --sb-opacity 0.4s ease;
}

.note[data-sb-theme="dark"] .note-text::-webkit-scrollbar-thumb:hover,
.note[data-sb-theme="dark"] .note-text::-webkit-scrollbar-thumb:active,
.note[data-sb-theme="dark"][data-scrolling] .note-text::-webkit-scrollbar-thumb {
    --sb-opacity: 0.35;
}

/* 深色底 → 浅色滚动条 */
.note[data-sb-theme="light"] .note-text::-webkit-scrollbar-thumb {
    --sb-opacity: 0.2;
    background: rgba(255, 255, 255, var(--sb-opacity));
    border-radius: 3px;
    transition: --sb-opacity 0.4s ease;
}

.note[data-sb-theme="light"] .note-text::-webkit-scrollbar-thumb:hover,
.note[data-sb-theme="light"] .note-text::-webkit-scrollbar-thumb:active,
.note[data-sb-theme="light"][data-scrolling] .note-text::-webkit-scrollbar-thumb {
    --sb-opacity: 0.5;
}

.note .note-text:empty::before {
    content: "双击编辑内容...";
    color: var(--text-color, #2c3e50);
    opacity: 0.4;
    font-style: italic;
    font-weight: 400;
}

.note .note-time {
    position: absolute;
    bottom: 10px;
    left: 16px;
    font-size: 15px;
    color: var(--text-color, #2c3e50);
    opacity: 0.75;
    pointer-events: none;
    letter-spacing: 0.3px;
    font-weight: 400;
}

/* 操作按钮呼吸式闪烁（未悬停时隐约可见） */
@keyframes actionsBreathe {
    0%, 100% {
        opacity: 0.12;
    }
    50% {
        opacity: 0.25;
    }
}

.note .note-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateY(-6px);
    animation: actionsBreathe 3s ease-in-out infinite;
}

.note:hover .note-actions {
    opacity: 1;
    transform: translateY(0);
    animation: none;
}

.note .note-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* 【优化 3】改为高饱和实色背景，彻底移除在旋转容器中导致文字图标整体变糊的 backdrop-filter */
    background: #ffffff; 
    color: #555;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.note .note-btn:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.note .note-btn.edit-btn:hover {
    background: rgba(33, 150, 243, 0.85);
    color: #fff;
    box-shadow: 0 2px 10px rgba(33, 150, 243, 0.3);
}

.note .note-btn.delete-btn:hover {
    background: rgba(233, 69, 96, 0.85);
    color: #fff;
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.3);
}

.note .note-btn.color-btn:hover {
    background: rgba(255, 193, 7, 0.85);
    color: #fff;
    box-shadow: 0 2px 10px rgba(255, 193, 7, 0.3);
}

/* ===== 颜色选择弹出面板 ===== */
.color-picker-popup {
    position: fixed;
    z-index: 3000;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
    padding: 16px 16px 20px;
    width: 240px;
    animation: popupIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

@keyframes popupIn {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(-8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.color-picker-popup .popup-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: center;
}

.color-picker-popup .popup-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    justify-content: center;
}

.color-picker-popup .popup-colors .color-opt {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}

.color-picker-popup .popup-colors .color-opt:hover {
    transform: scale(1.18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.color-picker-popup .popup-colors .color-opt.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.3);
    transform: scale(1.12);
}

.color-picker-popup .popup-divider {
    height: 2px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 1px;
    margin: 10px 0;
}

.color-picker-popup .popup-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.color-picker-popup .popup-custom label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
}

.color-picker-popup .popup-custom .popup-color-preview {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    cursor: pointer;
    transition: var(--transition);
}

.color-picker-popup .popup-custom .popup-color-preview:hover {
    transform: scale(1.08);
}

/* ===== 模态框 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--surface);
    border-radius: 16px;
    width: 480px;
    max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.93);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(233, 69, 96, 0.3);
    color: var(--primary-hover);
}

.modal-body {
    padding: 20px 24px;
}

.modal-body textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: #f8f9fa;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    transition: var(--transition);
    outline: none;
}

.modal-body textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

.modal-body textarea::placeholder {
    color: var(--text-secondary);
}

/* 文本框滚动条 */
.modal-body textarea::-webkit-scrollbar {
    width: 6px;
}

.modal-body textarea::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body textarea::-webkit-scrollbar-thumb {
    --sb-opacity: 0.15;
    background: rgba(0, 0, 0, var(--sb-opacity));
    border-radius: 3px;
    transition: --sb-opacity 0.4s ease;
}

.modal-body textarea::-webkit-scrollbar-thumb:hover,
.modal-body textarea::-webkit-scrollbar-thumb:active,
#modalTextarea[data-scrolling]::-webkit-scrollbar-thumb {
    --sb-opacity: 0.35;
}

/* 深色模式文本框滚动条 */
[data-theme="dark"] .modal-body textarea::-webkit-scrollbar-thumb {
    --sb-opacity: 0.2;
    background: rgba(255, 255, 255, var(--sb-opacity));
}

[data-theme="dark"] .modal-body textarea::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .modal-body textarea::-webkit-scrollbar-thumb:active,
[data-theme="dark"] #modalTextarea[data-scrolling]::-webkit-scrollbar-thumb {
    --sb-opacity: 0.5;
}

.modal-options {
    margin-top: 16px;
}

.modal-options label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.color-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-opt {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
    flex-shrink: 0;
}

.color-opt:hover {
    transform: scale(1.18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.color-opt.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.3);
    transform: scale(1.12);
}

.color-custom-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    cursor: pointer;
    transition: var(--transition);
}

.color-custom-wrap:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
}

.color-custom-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.color-custom-preview {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.12);
    display: inline-block;
    flex-shrink: 0;
    transition: var(--transition);
}

/* ===== 自定义取色器弹窗 ===== */
.color-picker-custom {
    position: fixed;
    z-index: 3000;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
    padding: 18px;
    width: 260px;
    animation: popupIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.color-picker-custom .cp-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
}

/* SV 调色板 */
.cp-palette-wrap {
    position: relative;
    width: 100%;
    height: 180px;
    border-radius: 10px;
    overflow: hidden;
    cursor: crosshair;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.cp-palette-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.cp-palette-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2.5px solid #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: none;
}

/* 色相滑块 */
.cp-hue-wrap {
    position: relative;
    width: 100%;
    height: 16px;
    border-radius: 8px;
    background: linear-gradient(to right,
        #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
    cursor: pointer;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.cp-hue-thumb {
    position: absolute;
    top: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2.5px solid #fff;
    background: #f00;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    transform: translateX(-50%);
    transition: none;
}

/* 底部颜色信息 */
.cp-footer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cp-preview {
    width: 40px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.cp-hex-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'FangSong', '仿宋', STFangsong, serif;
    color: var(--text);
    background: #f8f9fa;
    outline: none;
    transition: var(--transition);
}

.cp-hex-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.15);
}

.cp-hex-input::placeholder {
    color: #aaa;
    font-style: italic;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 24px 20px;
}

/* ===== 空状态 ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 80px 20px;
    color: var(--text-secondary);
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.empty-state .empty-icon {
    font-size: 72px;
    margin-bottom: 20px;
    opacity: 0.5;
    animation: emptyBounce 2s ease-in-out infinite;
}

@keyframes emptyBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.empty-state h2 {
    font-size: 22px;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 600;
}

.empty-state p {
    font-size: 15px;
    max-width: 300px;
    line-height: 1.6;
}

.empty-state .btn-empty-add {
    margin-top: 20px;
    padding: 10px 28px;
    font-size: 15px;
}

/* ===== 全局滚动条 ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    --sb-opacity: 0.12;
    background: rgba(0, 0, 0, var(--sb-opacity));
    border-radius: 4px;
    border: 1px solid transparent;
    background-clip: padding-box;
    transition: --sb-opacity 0.4s ease;
}

::-webkit-scrollbar-thumb:hover,
html[data-scrolling] ::-webkit-scrollbar-thumb {
    --sb-opacity: 0.32;
}

::-webkit-scrollbar-thumb:active {
    --sb-opacity: 0.45;
}

/* 深色模式全局滚动条 */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    --sb-opacity: 0.18;
    background: rgba(255, 255, 255, var(--sb-opacity));
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] html[data-scrolling] ::-webkit-scrollbar-thumb {
    --sb-opacity: 0.45;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:active {
    --sb-opacity: 0.55;
}



/* ===== 响应式 ===== */
@media (max-width: 640px) {
    .toolbar {
        padding: 10px 14px;
        justify-content: center;
    }

    .toolbar-title h1 {
        font-size: 18px;
    }

    .toolbar-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn {
        padding: 7px 14px;
        font-size: 13px;
    }

    .board {
        padding: 130px 12px 40px;
        justify-content: center;
        gap: 16px;
    }

    .note {
        width: calc(100% - 8px);
        max-width: 340px;
    }

    .modal {
        width: calc(100vw - 20px);
        max-width: 100vw;
        border-radius: 14px;
        margin: 10px;
    }

    .modal-header {
        padding: 16px 18px 0;
    }

    .modal-body {
        padding: 14px 18px;
    }

    .modal-footer {
        padding: 0 18px 16px;
    }

    .note-count {
        width: 100%;
        text-align: center;
    }
}

/* ===== 确认弹窗 ===== */
.modal-confirm {
    width: 380px;
    text-align: center;
}

.confirm-body {
    padding: 32px 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.confirm-icon {
    font-size: 48px;
    margin-bottom: 4px;
}

.confirm-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.confirm-message {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 280px;
}

.confirm-footer {
    padding: 0 24px 24px;
    justify-content: center;
    gap: 12px;
}

.confirm-footer .btn {
    min-width: 100px;
}

/* ===== 主题切换按钮 ===== */
.btn-theme {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-theme:hover {
    background: rgba(233, 69, 96, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ===== 自动保存指示器 ===== */
.save-indicator {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 5000;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease, background 0.35s ease, color 0.35s ease;
    pointer-events: none;
    box-shadow: var(--toast-shadow);
    white-space: nowrap;
}

.save-indicator.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===== 撤销 Toast ===== */
.undo-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease, background 0.35s ease, color 0.35s ease;
    box-shadow: var(--toast-shadow);
    white-space: nowrap;
}

.undo-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.btn-undo {
    background: var(--primary);
    color: #fff;
    padding: 5px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-undo:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

[data-theme="dark"] .btn-undo {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===== 空状态快捷新建按钮 ===== */
.btn-empty-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: linear-gradient(135deg, var(--primary), #d63851);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: 0 4px 18px rgba(233, 69, 96, 0.35);
    animation: pulse 2.5s ease-in-out infinite;
}

.btn-empty-add:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(233, 69, 96, 0.45);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 18px rgba(233, 69, 96, 0.35);
    }
    50% {
        box-shadow: 0 4px 30px rgba(233, 69, 96, 0.5);
    }
}

/* ===== 深色模式下便利贴样式微调 ===== */
[data-theme="dark"] .note {
    border-color: rgba(255, 255, 255, 0.08);
    
    /* 【核心修复】彻底删除 filter: brightness(0.88) saturate(0.85); */
    
    /* 【核心修复】改用线性渐变半透明黑遮罩叠在 inline 背景上。
       这种写法能完美、优雅地调暗背景，并且不触发浏览器的重绘滤镜，100% 保护文字清晰度 */
    background-image: linear-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15)) !important;
}

[data-theme="dark"] .note::after {
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.2) 0%, transparent 70%);
}

[data-theme="dark"] .note .note-btn {
    /* 【优化 4】深色模式下，按钮采用半实色，杜绝半透明滤层带来的模糊 */
    background: #243447; 
    color: #ccc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .note .note-btn:hover {
    background: #2c3e50;
}

[data-theme="dark"] .btn-clear {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .btn-clear:hover {
    background: rgba(255, 107, 129, 0.15);
    color: var(--primary);
    border-color: rgba(255, 107, 129, 0.25);
}

[data-theme="dark"] .btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .modal-body textarea {
    background: #0f1419;
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

[data-theme="dark"] .modal-body textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.2);
}

[data-theme="dark"] .cp-hex-input {
    background: #0f1419;
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

[data-theme="dark"] .modal-close {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

[data-theme="dark"] .modal-close:hover {
    background: rgba(255, 107, 129, 0.3);
    color: var(--primary);
}

[data-theme="dark"] .color-custom-wrap {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .color-custom-wrap:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .color-picker-popup {
    background: #1a2332;
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .color-picker-popup .popup-divider {
    background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .color-picker-popup .popup-custom .popup-color-preview {
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .color-picker-custom {
    background: #1a2332;
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .cp-palette-wrap {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .cp-hue-wrap {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .cp-preview {
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .note-count {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-theme {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

[data-theme="dark"] .btn-theme:hover {
    background: rgba(255, 107, 129, 0.18);
}

/* ===== 自定义 Tooltip（替代浏览器原生 title） ===== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    /* 默认向下弹出，避免被工具栏/卡片上边缘遮挡 */
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: 5px 10px;
    background: var(--toast-bg);
    color: var(--toast-text);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 4000;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 颜色色块 tooltip 调小间距，并确保在色块上方 */
.color-opt[data-tooltip]::after {
    top: calc(100% + 4px);
    z-index: 10;
}

.color-options .color-opt[data-tooltip]::after {
    top: calc(100% + 4px);
    z-index: 10;
}

/* ==========================================================================
   【终极修复】便利贴三个按钮及切换按钮的 Tooltip 变形与模糊问题
   ========================================================================== */

/* 1. 便利贴内三个按钮的 Tooltip 默认状态（未悬停时）：
   仅抵消卡片本身的旋转 (--rot)，使提示框在初始状态下就保持绝对水平 */
.note [data-tooltip]::after {
    transform: translateX(-50%) translateY(-4px);
}

.note [data-tooltip]:hover::after {
    transform: translateX(-50%) translateY(0);
}
