/* ==================== CSS 变量 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg-primary: #f5f3ff; --bg-secondary: #edeafe; --bg-card: #ffffff;
    --text-primary: #333333; --text-secondary: #666666; --text-muted: #999999;
    --primary-color: #7c3aed; --primary-hover: #6d28d9; --secondary-color: #8b5cf6;
    --border-color: #e5e7eb; --border-hover: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px;
    --transition: all 0.2s ease;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary); min-height: 100vh; line-height: 1.6;
}
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }
.header {
    background: var(--bg-card); box-shadow: var(--shadow-sm); padding: 16px 0;
    position: sticky; top: 0; z-index: 100; backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.9);
}
.header-content {
    max-width: 1400px; margin: 0 auto; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.logo {
    font-size: 20px; font-weight: 600; color: var(--primary-color);
    text-decoration: none; display: flex; align-items: center; gap: 8px;
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-btn {
    background: none; border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 8px 12px; font-size: 14px; color: var(--text-primary); cursor: pointer;
    transition: var(--transition); display: flex; align-items: center; gap: 4px;
}
.header-btn:hover { background: var(--bg-primary); border-color: var(--primary-color); color: var(--primary-color); }

/* ==================== 搜索区域 ==================== */
.search-section { margin: 32px 0 48px; }
.search-box { max-width: 800px; margin: 0 auto; position: relative; }
.search-input-wrapper {
    display: flex; gap: 0; background: var(--bg-card); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--border-color);
}
.search-input {
    flex: 1; padding: 16px 20px; border: none; outline: none; font-size: 16px;
    background: transparent; color: var(--text-primary);
}
.search-input::placeholder { color: var(--text-muted); }
.clear-btn {
    padding: 0 16px; display: flex; align-items: center; cursor: pointer;
    color: var(--text-muted); font-size: 24px; transition: var(--transition);
}
.clear-btn:hover { color: var(--text-primary); }
.search-btn {
    background: var(--primary-color); color: white; border: none;
    padding: 0 24px; font-size: 16px; font-weight: 500; cursor: pointer;
    transition: var(--transition);
}
.search-btn:hover { background: var(--primary-hover); }

/* 搜索历史/建议下拉框 */
.search-suggestions {
    position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color); margin-top: 8px; max-height: 300px;
    overflow-y: auto; display: none; z-index: 1000;
}
.search-suggestions.show { display: block; }
.suggestion-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border-color);
    cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; gap: 12px;
}
.suggestion-item:hover { background: var(--bg-primary); }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-icon {
    width: 24px; height: 24px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.suggestion-content { flex: 1; min-width: 0; }
.suggestion-text { font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-subtext { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.suggestion-type {
    font-size: 10px; padding: 2px 6px; border-radius: 4px;
    background: var(--bg-primary); color: var(--text-secondary);
}

/* 搜索结果下拉框 */
.search-results {
    position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color); margin-top: 8px; max-height: 400px;
    overflow-y: auto; display: none; z-index: 1000;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border-color);
    cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; gap: 12px;
}
.search-result-item:hover { background: var(--bg-primary); }
.search-result-item:last-child { border-bottom: none; }
.search-result-icon {
    width: 24px; height: 24px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.search-result-title { font-weight: 500; color: var(--text-primary); }
.search-result-url { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ==================== 主容器 ==================== */
.main-container {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px; margin-top: 24px;
}

/* ==================== 分组卡片 ==================== */
.group-card {
    background: var(--bg-card); border-radius: var(--radius-xl); padding: 20px;
    box-shadow: var(--shadow-md); border: 1px solid var(--border-color);
    transition: var(--transition); cursor: grab;
}
.group-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.group-card.sortable-ghost { opacity: 0.4; }
.group-card.sortable-drag { opacity: 0.9; }
.group-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color);
}
.group-header:has(.group-actions:empty),
.group-header:not(:has(.group-actions)) {
    justify-content: flex-start;
}
.group-title {
    font-size: 16px; font-weight: 600; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}
.group-icon {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; background: transparent;
    color: var(--text-primary);
}
.group-actions { display: flex; gap: 6px; }
.group-btn {
    background: none; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 4px 8px; font-size: 11px; color: var(--text-secondary); cursor: pointer;
    transition: var(--transition);
}
.group-btn:hover {
    background: var(--bg-primary); border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ==================== 链接卡片 ==================== */
.links-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.link-card {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-primary); border-radius: var(--radius-md);
    padding: 10px 12px; text-decoration: none; color: var(--text-primary);
    transition: var(--transition); border: 1px solid var(--border-color);
    position: relative; overflow: hidden; cursor: pointer;
}
.link-card:hover {
    background: var(--bg-secondary); transform: translateX(2px);
    box-shadow: var(--shadow-sm); border-color: var(--primary-color);
}
.link-card.sortable-ghost { opacity: 0.4; }
.link-card.sortable-drag { opacity: 0.9; box-shadow: var(--shadow-lg); }
.link-card-icon {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: white; flex-shrink: 0; font-weight: 600;
}
.link-card-content { flex: 1; min-width: 0; }
.link-card-title {
    font-weight: 500; font-size: 13px; margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-card-url {
    font-size: 10px; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-card-actions {
    display: flex; gap: 4px; opacity: 0; transition: var(--transition);
}
.link-card:hover .link-card-actions { opacity: 1; }
.link-card-action-btn {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 4px; padding: 2px 4px; font-size: 11px;
    cursor: pointer; transition: var(--transition);
}
.link-card-action-btn:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* ==================== 添加分组按钮 ==================== */
.add-group-fab {
    position: fixed; bottom: 30px; right: 30px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    z-index: 90;
}
.add-group-fab:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}
.add-group-fab:active { transform: scale(0.95); }

/* ==================== 功能说明卡片 ==================== */
.feature-card {
    background: var(--bg-card); border-radius: var(--radius-xl); padding: 20px;
    box-shadow: var(--shadow-md); border: 1px solid var(--border-color);
    transition: var(--transition); cursor: grab;
}
.feature-card.sortable-ghost { opacity: 0.4; }
.feature-card.sortable-drag { opacity: 0.9; }
.feature-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color);
}
.feature-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.feature-actions { display: flex; gap: 6px; }
.feature-action-btn {
    background: none; border: 1px solid var(--border-color); border-radius: 4px;
    padding: 4px 6px; font-size: 12px; cursor: pointer; transition: var(--transition);
}
.feature-action-btn:hover { background: var(--bg-primary); }
.feature-action-btn.danger:hover { background: #fee2e2; border-color: #ef4444; color: #ef4444; }
.feature-content {
    font-size: 13px; color: var(--text-secondary); line-height: 1.7;
    white-space: pre-wrap; word-break: break-all;
}

/* ==================== TODO 清单卡片 ==================== */
.todo-card {
    background: var(--bg-card); border-radius: var(--radius-xl); padding: 20px;
    box-shadow: var(--shadow-md); border: 1px solid var(--border-color);
    transition: var(--transition); cursor: grab;
}
.todo-card.sortable-ghost { opacity: 0.4; }
.todo-card.sortable-drag { opacity: 0.9; }
.todo-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color);
}
.todo-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.todo-actions { display: flex; gap: 6px; }
.todo-action-btn {
    width: 26px; height: 26px; border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--bg-primary); font-size: 16px; cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.todo-action-btn:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.todo-action-btn.danger:hover { background: #fee2e2; border-color: #ef4444; color: #ef4444; }
.todo-list { list-style: none; margin-bottom: 12px; }
.todo-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid var(--border-color);
}
.todo-item:last-child { border-bottom: none; }
.todo-checkbox {
    width: 18px; height: 18px; border: 2px solid var(--border-color);
    border-radius: 4px; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition); background: var(--bg-card);
}
.todo-checkbox:hover { border-color: var(--primary-color); }
.todo-checkbox.checked { background: var(--primary-color); border-color: var(--primary-color); color: white; }
.todo-checkbox.checked::after { content: '✓'; font-size: 12px; }
.todo-text { flex: 1; font-size: 13px; color: var(--text-primary); word-break: break-all; }
.todo-text.completed { text-decoration: line-through; color: var(--text-muted); }
.todo-delete-btn {
    background: none; border: none; font-size: 14px; cursor: pointer;
    opacity: 0; transition: var(--transition); padding: 2px 4px;
}
.todo-item:hover .todo-delete-btn { opacity: 1; }
.todo-delete-btn:hover { color: #ef4444; }
.todo-add-btn {
    width: 100%; padding: 10px; border: 1px dashed var(--border-color);
    border-radius: var(--radius-md); background: var(--bg-primary);
    color: var(--text-secondary); font-size: 13px; cursor: pointer;
    transition: var(--transition); display: flex; align-items: center;
    justify-content: center; gap: 6px;
}
.todo-add-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* ==================== 编辑指示器 ==================== */
.edit-indicator {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--primary-color); color: white; padding: 12px 24px;
    border-radius: var(--radius-xl); display: flex; align-items: center;
    gap: 12px; box-shadow: var(--shadow-lg); z-index: 1000;
}
.exit-edit-btn {
    background: rgba(255, 255, 255, 0.2); border: 1px solid rgba(255, 255, 255, 0.3);
    color: white; padding: 4px 12px; border-radius: var(--radius-md);
    font-size: 12px; cursor: pointer; transition: var(--transition);
}
.exit-edit-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* ==================== 模态框 ==================== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5); display: none;
    align-items: center; justify-content: center; z-index: 2000;
    backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-card); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); width: 90%; max-width: 500px;
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.modal-close {
    background: none; border: none; font-size: 24px; color: var(--text-muted);
    cursor: pointer; padding: 0; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); transition: var(--transition);
}
.modal-close:hover { background: var(--bg-primary); color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 20px 24px; border-top: 1px solid var(--border-color);
    display: flex; justify-content: flex-end; gap: 12px;
}
.form-group { margin-bottom: 20px; }
.form-label {
    display: block; font-size: 14px; font-weight: 500;
    color: var(--text-primary); margin-bottom: 8px;
}
.form-input {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); font-size: 14px; color: var(--text-primary);
    background: var(--bg-card); transition: var(--transition);
}
.form-input:focus {
    outline: none; border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.btn {
    padding: 10px 20px; border-radius: var(--radius-md); font-size: 14px;
    font-weight: 500; cursor: pointer; transition: var(--transition); border: none;
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
    background: var(--bg-primary); color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--bg-secondary); border-color: var(--border-hover); }

/* 颜色选择器 */
.color-option {
    transition: var(--transition);
}
.color-option:hover {
    transform: scale(1.1);
}

/* ==================== Emoji 选择器 ==================== */
.emoji-picker {
    max-height: 280px; overflow-y: auto; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 12px; background: var(--bg-card);
    margin-top: 8px;
}
.emoji-category {
    font-size: 12px; color: var(--text-muted); margin: 12px 0 8px;
    padding-bottom: 4px; border-bottom: 1px solid var(--border-color);
}
.emoji-category:first-child { margin-top: 0; }
.emoji-grid {
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
}
.emoji-option {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; cursor: pointer; transition: var(--transition);
    border: 1px solid var(--border-color); background: var(--bg-primary);
}
.emoji-option:hover { background: var(--bg-secondary); border-color: var(--primary-color); transform: scale(1.05); }
.emoji-option.selected { background: var(--primary-color); border-color: var(--primary-color); color: white; }
.emoji-input-row {
    display: flex; gap: 8px; margin-bottom: 12px; align-items: center;
}
.emoji-preview {
    width: 40px; height: 40px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; background: var(--bg-primary); border: 1px solid var(--border-color);
}
.icon-type-select { display: flex; gap: 20px; margin-top: 8px; }
.icon-type-select label { display: flex; align-items: center; gap: 5px; cursor: pointer; font-size: 14px; color: var(--text-secondary); }
.icon-type-select input[type="radio"] { cursor: pointer; }

/* ==================== 主题选择器 ==================== */
.theme-selector {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: var(--bg-card); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); padding: 24px; width: 90%;
    max-width: 800px; max-height: 80vh; overflow-y: auto; display: none; z-index: 2000;
}
.theme-selector.show { display: block; }
.theme-selector-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color);
}
.theme-selector-title { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.theme-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.theme-option {
    background: var(--bg-primary); border: 2px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 16px; cursor: pointer;
    transition: var(--transition); position: relative;
}
.theme-option:hover { border-color: var(--primary-color); transform: translateY(-2px); }
.theme-option.active { border-color: var(--primary-color); background: rgba(124, 58, 237, 0.05); }
.theme-preview {
    width: 100%; height: 80px; border-radius: var(--radius-md); margin-bottom: 12px;
}
.theme-name { font-size: 14px; font-weight: 500; color: var(--text-primary); text-align: center; }
.theme-check {
    position: absolute; top: 12px; right: 12px; width: 24px; height: 24px;
    background: var(--primary-color); color: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
    opacity: 0; transition: var(--transition);
}
.theme-option.active .theme-check { opacity: 1; }

/* ==================== 右键菜单 ==================== */
.context-menu {
    position: fixed; background: var(--bg-card); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
    min-width: 160px; z-index: 3000; display: none;
}
.context-menu.show { display: block; }
.context-menu-item {
    padding: 12px 16px; cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-primary);
}
.context-menu-item:hover { background: var(--bg-primary); }
.context-menu-item.danger { color: #ef4444; }
.context-menu-item.danger:hover { background: rgba(239, 68, 68, 0.1); }
.context-menu-item.disabled { opacity: 0.5; cursor: not-allowed; }
.context-menu-item.disabled:hover { background: none; }

/* ==================== 其他组件 ==================== */
.footer {
    text-align: center; padding: 24px 20px; margin-top: 48px;
    color: var(--text-muted); font-size: 14px; border-top: 1px solid var(--border-color);
}
.back-to-top {
    position: fixed; bottom: 20px; right: 20px; width: 48px; height: 48px;
    background: var(--primary-color); color: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: var(--shadow-md); opacity: 0;
    visibility: hidden; transition: var(--transition); z-index: 100;
}
.back-to-top.show { opacity: 1; visibility: visible; }
.back-to-top:hover {
    background: var(--primary-hover); transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.drag-hint {
    font-size: 11px; color: var(--text-muted); margin-top: 4px;
}

/* ==================== PWA 安装提示 ==================== */
.pwa-install-prompt {
    position: fixed; bottom: 100px; right: 30px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 12px 16px;
    box-shadow: var(--shadow-lg); z-index: 99;
    display: flex; align-items: center; gap: 12px;
    animation: slideInRight 0.3s ease;
}
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.pwa-install-prompt span {
    font-size: 13px; color: var(--text-primary);
}
.install-btn {
    background: var(--primary-color); color: white;
    border: none; padding: 6px 12px; border-radius: var(--radius-md);
    font-size: 12px; cursor: pointer; transition: var(--transition);
}
.install-btn:hover { background: var(--primary-hover); }
.dismiss-btn {
    background: none; border: none; font-size: 18px;
    color: var(--text-muted); cursor: pointer; padding: 0;
    width: 24px; height: 24px; display: flex;
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}
.dismiss-btn:hover { background: var(--bg-primary); color: var(--text-primary); }

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .container { padding: 16px; }
    .header-content { padding: 0 16px; }
    .header-actions { gap: 4px; }
    .header-btn { padding: 6px 10px; font-size: 12px; }
    .main-container { grid-template-columns: 1fr; gap: 16px; }
    .links-grid { grid-template-columns: repeat(2, 1fr); }
    .modal { width: 95%; max-width: 95%; }
    .theme-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .pwa-install-prompt { right: 16px; bottom: 80px; flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .header-content { flex-direction: column; gap: 12px; }
    .search-btn { padding: 0 16px; }
    .pwa-install-prompt { display: none; }
}
