/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #141b2d;
    --bg-card: #1a2332;
    --text-primary: #f0f2f5;
    --text-secondary: #d0d4d8;
    --accent: #5ba8ff;
    --accent-hover: #6bb8ff;
    --border: rgba(255, 255, 255, 0.15);
    --shadow: rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, rgba(10, 14, 39, 0.95) 0%, rgba(15, 22, 41, 0.95) 100%);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.5s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.toast {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(20, 25, 40, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text-primary);
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: min(520px, calc(100vw - 24px));
    text-align: center;
    backdrop-filter: blur(10px) saturate(180%);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.toast-error {
    border-color: rgba(255, 87, 87, 0.35);
}

/* 背景层，避免切换闪烁并添加渐变过渡 */
.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 1;
    transition: opacity 0.6s ease;
}

/* 顶部导航栏 */
.top-nav {
    background: rgba(30, 35, 50, 0.65);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 5px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(15px) saturate(180%);
    position: sticky;
    top: 0;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow: hidden;
    max-height: 1000px;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.35s ease, margin-bottom 0.35s ease, padding-top 0.35s ease, padding-bottom 0.35s ease, border-width 0.35s ease;
}

.top-nav.is-collapsed {
    max-height: 0;
    opacity: 0;
    transform: translateY(-12px);
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    pointer-events: none;
}

.top-nav.tools-collapsed {
    gap: 0;
    padding-top: 10px;
    padding-bottom: 10px;
}

.top-nav-toggle-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.top-nav-toggle-btn {
    width: 46px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(10px) saturate(180%);
}

.top-nav-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.top-nav-toggle-btn svg {
    transition: transform 0.25s ease;
}

body.top-nav-tools-collapsed #topNavToggleBtn svg {
    transform: rotate(180deg);
}

body.search-module-collapsed #searchModuleToggleBtn svg {
    transform: rotate(180deg);
}

.nav-tools-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    overflow: hidden;
    max-height: 120px;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.35s ease, margin 0.35s ease;
}

.top-nav.tools-collapsed .nav-tools-row {
    max-height: 0;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    margin: 0;
}

.top-nav.tools-collapsed .nav-links-row {
    border-top: 0;
    padding-top: 0;
}

.nav-menu-tools {
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-left-tools,
.nav-right-tools {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-links-row {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.open-all-btn {
    position: absolute;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.open-all-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.nav-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.nav-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

/* 浅色模式变量 */
body.light-mode {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --accent: #0066cc;
    --accent-hover: #0052a3;
    --border: rgba(0, 0, 0, 0.1);
    --shadow: rgba(0, 0, 0, 0.1);
}

body.light-mode .top-nav,
body.light-mode .search-container {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .nav-menu-tool-btn {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--border);
    color: var(--text-secondary);
}

body.light-mode .nav-menu-tool-btn:hover {
    background: var(--accent);
    color: #fff;
}

body.light-mode #searchInput {
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
}

body.light-mode .link-item {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .link-item:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

body.light-mode .engine-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--text-secondary);
}

body.light-mode .engine-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

body.light-mode .random-bg-btn {
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--text-secondary) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}

body.light-mode .random-bg-btn:hover {
    background: var(--accent) !important;
    color: #fff !important;
}


.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    flex: 1;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.nav-link.is-deleting {
    pointer-events: none;
    color: transparent !important;
}

.nav-link .nav-delete-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(250, 204, 21, 0.25);
    border-top-color: rgba(250, 204, 21, 0.95);
    border-right-color: rgba(250, 204, 21, 0.85);
    animation: nav-delete-spin 0.8s linear infinite;
    z-index: 2;
    pointer-events: none;
}

body.light-mode .nav-link .nav-delete-spinner {
    border-color: rgba(250, 204, 21, 0.25);
    border-top-color: rgba(250, 204, 21, 0.95);
    border-right-color: rgba(250, 204, 21, 0.85);
}

@keyframes nav-delete-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.nav-menu-tools {
    display: flex;
    gap: 5px;
    margin-top: 0;
}

.nav-menu-tool-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(20, 25, 40, 0.8);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.nav-menu-tool-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.35);
}

.nav-link:hover {
    background: var(--bg-card);
    color: var(--accent);
    transform: translateY(-2px);
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
}

.nav-links.sort-mode .nav-link {
    cursor: grab;
    outline: 1px dashed rgba(255, 255, 255, 0.25);
    outline-offset: 2px;
    user-select: none;
}

.nav-links.sort-mode .nav-link:active {
    cursor: grabbing;
}

.nav-links.sort-mode .nav-link.dragging {
    opacity: 0.55;
    transform: scale(0.98);
}

/* 搜索框区域 */
.search-container {
    background: rgba(30, 35, 50, 0.65);
    border-radius: 12px;
    padding: 5px 25px 25px;
    margin-bottom: 5px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(15px) saturate(180%);
    position: sticky;
    top: 140px;
    z-index: 999;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: top 0.35s ease;
}

body.top-nav-collapsed .search-container {
    top: 20px;
}

.search-container.module-collapsed {
    padding-top: 12px;
    padding-bottom: 12px;
}

.search-container.module-collapsed .top-nav-toggle-row {
    margin-bottom: 0;
    padding-top: 2px;
    padding-bottom: 2px;
}

body.compact-collapse-controls .search-container {
    padding-top: 2px;
    padding-bottom: 2px;
}

body.compact-collapse-controls .top-nav-toggle-row {
    margin-bottom: 0;
    padding-top: 2px;
    padding-bottom: 2px;
}

.search-container.module-collapsed .search-box,
.search-container.module-collapsed .translate-buttons,
.search-container.module-collapsed .search-engines {
    display: none;
}

body.top-nav-tools-collapsed .search-container {
    top: 90px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    background: rgba(74, 158, 255, 0.15);
    border-radius: 10px;
    padding: 10px;
}

.search-input-wrapper {
    flex: 1 1 auto;
    max-width: none;
    min-width: 260px;
    position: relative;
}

.primary-engines {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    margin-left: auto;
}

#searchInput {
    width: 100%;
    padding: 15px 20px;
    background: rgba(20, 25, 40, 0.6);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

/* 站内搜索按钮 */
#siteSearchBtn {
    padding: 12px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

#siteSearchBtn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(30, 35, 50, 0.95);
    border: 2px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px) saturate(180%);
    z-index: 1000;
    display: none;
    margin-top: 5px;
}

.search-results-dropdown.show {
    display: block;
}

.search-result-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(91, 168, 255, 0.2);
    color: var(--accent);
}

.search-result-item .link-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.search-result-item .link-name {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.search-result-item:hover .link-name {
    color: var(--accent);
}

.search-result-category {
    padding: 8px 20px;
    background: rgba(20, 25, 40, 0.5);
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-results-dropdown::-webkit-scrollbar {
    width: 8px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: rgba(20, 25, 40, 0.3);
    border-radius: 10px;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: rgba(91, 168, 255, 0.3);
    border-radius: 10px;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
    color: var(--text-secondary);
    font-size: 14px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(91, 168, 255, 0.5);
}

.search-btn {
    padding: 15px 30px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.random-bg-btn {
    background: rgba(20, 25, 40, 0.6) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border) !important;
}

.random-bg-btn:hover {
    background: rgba(30, 40, 60, 0.8) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.translate-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.translate-btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    transition: all 0.3s ease;
    white-space: nowrap;
    color: #fff;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.import-btn {
    background: #28a745;
    border-bottom: 3px solid #1f7a36;
}

.import-btn:hover {
    background: #1f7a36;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.35);
}

.export-btn {
    background: #007bff;
    border-bottom: 3px solid #0056b3;
}

.export-btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.35);
}

.google-translate-btn {
    background: #4285F4;
    border-bottom: 3px solid #1a73e8;
}

.google-translate-btn:hover {
    background: #1a73e8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.4);
}

.eudic-translate-btn {
    background: #4A90E2;
    border-bottom: 3px solid #357ABD;
}

.eudic-translate-btn:hover {
    background: #357ABD;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

.youdao-translate-btn {
    background: #E53E3E;
    border-bottom: 3px solid #C53030;
}

.youdao-translate-btn:hover {
    background: #C53030;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.4);
}

.search-engines {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    justify-content: center;
    margin-top: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(91, 168, 255, 0.3) transparent;
}

.search-engines::-webkit-scrollbar {
    height: 6px;
}

.search-engines::-webkit-scrollbar-track {
    background: transparent;
}

.search-engines::-webkit-scrollbar-thumb {
    background: rgba(91, 168, 255, 0.3);
    border-radius: 3px;
}

.search-engines::-webkit-scrollbar-thumb:hover {
    background: rgba(91, 168, 255, 0.5);
}

.engine-btn {
    padding: 10px 10px;
    background: rgba(20, 25, 40, 0.6);
    border: 1px solid var(--border);
    border-bottom: 3px solid;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 88px;
    min-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    box-sizing: border-box;
}

/* 不同平台的底部颜色 */
.engine-btn[data-engine="google"] {
    border-bottom-color: #4285F4;
}

.engine-btn[data-engine="baidu"] {
    border-bottom-color: #2932E1;
}

.engine-btn[data-engine="bing"] {
    border-bottom-color: #008373;
}

.engine-btn[data-engine="github"] {
    border-bottom-color: #6f42c1;
}

.engine-btn[data-engine="youtube"] {
    border-bottom-color: #FF0000;
}

.engine-btn[data-engine="gpt"] {
    border-bottom-color: #10a37f;
}

.engine-btn[data-engine="skywork"] {
    border-bottom-color: #0078D7;
}

.engine-btn[data-engine="perplexity"] {
    border-bottom-color: #3B82F6;
}

.engine-btn[data-engine="semanticscholar"] {
    border-bottom-color: #1B6AC9;
}

.engine-btn[data-engine="bilibili"] {
    border-bottom-color: #00A1D6;
}

.engine-btn[data-engine="douyin"] {
    border-bottom-color: #FF0050;
}

.engine-btn[data-engine="kuaishou"] {
    border-bottom-color: #FF6A00;
}

.engine-btn[data-engine="xiaohongshu"] {
    border-bottom-color: #FF2442;
}

.engine-btn[data-engine="toutiao"] {
    border-bottom-color: #FF2741;
}

.engine-btn[data-engine="zhihu"] {
    border-bottom-color: #0084FF;
}

.engine-btn[data-engine="douban"] {
    border-bottom-color: #2E963D;
}

.engine-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    border-bottom-color: var(--accent);
}

/* 分类区域 */
.category-section {
    margin-bottom: 40px;
    animation: fadeIn 0.5s ease-in;
    background: rgba(30, 35, 50, 0.4);
    border-radius: 12px;
    padding: 25px;
    backdrop-filter: blur(15px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    transition: all 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.category-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    flex-wrap: nowrap;
    width: 100%;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.category-title:hover {
    color: var(--accent);
}

.category-title.editing {
    color: var(--accent);
}

.category-title input {
    background: transparent;
    border: 2px solid var(--accent);
    border-radius: 6px;
    padding: 5px 10px;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
    min-width: 100px;
    outline: none;
    flex-shrink: 0;
}

/* 大类悬停时的功能按钮 */
.category-actions-hover {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 15px;
    z-index: 10;
    pointer-events: none;
}

.category-section:hover .category-actions-hover {
    display: flex;
}

.category-tag-btn,
.category-delete-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.category-tag-btn {
    background: rgba(74, 158, 255, 0.8);
    color: #fff;
    margin-left: 15px;
}

.category-tag-btn:hover {
    background: rgba(74, 158, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.category-delete-btn {
    background: rgba(255, 77, 77, 0.8);
    color: #fff;
    margin-right: 15px;
}

.category-delete-btn:hover {
    background: rgba(255, 77, 77, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 77, 77, 0.3);
}

/* 大类标记状态 */
.category-section.tagged {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(91, 168, 255, 0.3);
}

.category-title>span {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.category-title>span::before {
    content: '';
    width: 4px;
    height: 28px;
    background: var(--accent);
    border-radius: 2px;
}

.category-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.category-section:hover .category-actions,
.category-title.editing .category-actions {
    opacity: 1;
    visibility: visible;
}

.category-btn {
    padding: 8px 16px;
    background: rgba(20, 25, 40, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    white-space: nowrap;
    backdrop-filter: blur(10px);
}

.category-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.add-link-btn {
    background: rgba(74, 158, 255, 0.2);
    border-color: var(--accent);
}

.import-bookmark-btn {
    background: rgba(40, 167, 69, 0.2);
    border-color: #28a745;
}

.import-bookmark-btn:hover {
    background: #28a745;
    border-color: #28a745;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.category-grid {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 100%;
}

.category-subsection {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    backdrop-filter: none;
    transition: none;
    border: none;
    margin-bottom: 30px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.category-subsection:hover {
    transform: none;
    box-shadow: none;
    background: transparent;
}

.subsection-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--accent);
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    position: relative;
}

/* 三级子部分 */
.category-subsubsection {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    backdrop-filter: none;
    transition: none;
    border: none;
    margin-bottom: 20px;
    margin-left: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.category-subsubsection:hover {
    transform: none;
    box-shadow: none;
    background: transparent;
}

.subsubsection-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-secondary);
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-left: 20px;
    width: 100%;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 16px;
    min-height: 50px;
    width: 100%;
    align-items: start;
    grid-auto-flow: row;
    padding: 5px 0;
}

.link-item-wrapper {
    position: relative;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    break-inside: avoid;
}

.link-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center content vertically */
    padding: 15px;
    background: rgba(20, 27, 45, 0.6);
    backdrop-filter: blur(12px) saturate(180%);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    cursor: pointer;
    aspect-ratio: 1;
    /* Make it square */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 编辑模式下显示移动光标 */
.category-section.edit-mode .link-item {
    cursor: move;
}

.link-item:hover {
    background: rgba(30, 40, 60, 0.8);
    border-color: var(--accent);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px rgba(91, 168, 255, 0.4), 0 0 0 1px rgba(91, 168, 255, 0.2);
}

.link-item-wrapper.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.link-item-wrapper.drag-over {
    border: 2px dashed var(--accent);
    border-radius: 12px;
}

/* Edit Link Modal */
.edit-link-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.edit-link-form label {
    font-weight: 600;
    color: var(--text-secondary);
}

body.dragging-active * {
    transition: none !important;
    animation: none !important;
}


.edit-link-form .modal-input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.edit-link-form .modal-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(91, 168, 255, 0.2);
}

/* Icon Styles - Large and Centered */
.link-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-bottom: auto;
    /* Push to top/center */
    margin-top: auto;
    transition: transform 0.3s ease;
}

.link-item:hover .link-icon-img {
    transform: scale(1.1);
}

/* Name Styles - Bottom of content */
.link-name {
    font-size: 13px;
    text-align: center;
    width: 100%;
    margin-top: auto;
    padding-top: 8px;
    word-break: break-word;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.link-actions {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: none;
    justify-content: center;
    align-items: center;
    gap: 8px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    backdrop-filter: blur(2px);
    pointer-events: none;
}

/* 只有在编辑模式下，链接悬停时才显示编辑/删除按钮 */
.category-section.edit-mode .link-item-wrapper:hover .link-actions {
    display: flex;
    pointer-events: auto;
}

/* 图标上传按钮 - 在编辑模式下显示在链接左上方 */
.upload-icon-btn {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(74, 158, 255, 0.9);
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    transition: all 0.2s ease;
    z-index: 11;
    pointer-events: auto;
    display: none;
}

.category-section.edit-mode .link-item-wrapper .upload-icon-btn {
    display: block;
}

.upload-icon-btn:hover {
    background: rgba(74, 158, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.4);
}

.link-actions button {
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    padding: 8px 16px;
    font-size: 14px;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.link-actions button:hover {
    transform: translateY(-2px);
}

.link-actions .edit-btn {
    background: #409eff;
}

.link-actions .edit-btn:hover {
    background: #66b1ff;
}

.link-actions .delete-btn {
    background: #f56c6c;
}

.link-actions .delete-btn:hover {
    background: #f78989;
}

.subsection-delete-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 77, 77, 0.15);
    border: 1px solid rgba(255, 77, 77, 0.7);
    border-radius: 6px;
    color: #ffdddd;
}

/* Custom Modal Styles */
.custom-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.custom-modal-content {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-modal h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 20px;
}

.custom-modal p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 15px;
}

.modal-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    font-size: 14px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.modal-btn.cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.modal-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.modal-btn.confirm {
    background: var(--accent);
    color: white;
}

.modal-btn.confirm:hover {
    background: var(--accent-hover);
}

.footer p {
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    text-align: center;
}


/* =========================================
   全局禁止选中图标样式
   ========================================= */
svg, img, button svg, button img, a svg, a img, .icon, [class*="icon"] {
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
}
