:root {
    --sidebar-bg: #2C2E2F;
    --panel-bg: #f9fbfd;
    --card-border: #eef2f6;
    --text-muted: #5f7d9c;
    --hover-bg: #2a3b4e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--panel-bg);
    height: 100vh;
    overflow: hidden;
}

/* 自定义滚动条 */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* 侧边栏样式 */
.sidebar {
    position: relative;
    background-color: var(--sidebar-bg);
    color: #b4c2d0;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: visible;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar:not(.collapsed) {
    width: 280px;
}

.sidebar-header {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #3f5570;
}

.sidebar-header .logo {
    font-size: 28px;
}

.sidebar-header .title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e6edf5;
    white-space: nowrap;
}

/* 分类树 */
.category-tree {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    margin: 20px 0;
    position: relative;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-tree::-webkit-scrollbar {
    display: none;
}

.tree-node {
    list-style: none;
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 0px 40px 0px 40px;     /* 原为 12px 40px，改为 6px 40px，与内层内边距协调 */
    cursor: pointer;
    color: #979898;
    transition: all 0.1s;
    font-size: 13px;
}

/* 图标和文字的包裹容器，负责下边框 */
.node-content-wrapper {
    display: flex;
    align-items: center;
    flex: 1;                 /* 占满剩余空间，将箭头推至右侧 */
    padding-bottom: 0;       /* 边框紧贴文字底部 */
    margin-right: 8px;        /* 与箭头保持间距 */
}

.child-nodes .tree-node-content .node-name {
    border-bottom: none;
}

.sidebar.collapsed .node-content-wrapper {
    border-bottom: none;      /* 折叠时隐藏边框，保持简洁 */
}

.sidebar.collapsed .tree-node-content {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar.collapsed .node-icon {
    margin-right: 0;
}

.tree-node-content:hover {
    color: #e6edf5;
}

.tree-node-content.active {
    color: #e6edf5;
}

.node-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.node-icon i {
    font-size: 13px;
    vertical-align: middle;
}

.node-icon img {
    max-width: 18px;
    max-height: 18px;
    object-fit: contain;
}

.node-name {
    flex: 1;
    white-space: nowrap;
}

.expand-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #8fa3bc;
    margin-left: auto;
    cursor: pointer;
    transition: transform 0.2s;
}

.expand-icon.expanded {
    transform: rotate(90deg);
}

.child-nodes {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.child-nodes.expanded {
    max-height: 500px;
}

.child-nodes .tree-node-content {
    padding-left: 72px;
}

.child-nodes .node-icon {
    display: none;
}

/* 折叠状态 */
.sidebar.collapsed .sidebar-header .title,
.sidebar.collapsed .tree-node-content .node-name,
.sidebar.collapsed .expand-icon,
.sidebar.collapsed .sidebar-footer span {
    display: none;
}

.sidebar.collapsed .tree-node-content {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar.collapsed .node-icon {
    margin-right: 0;
}

.sidebar.collapsed .node-icon i {
    font-size: 1.5rem;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid #3f5570;
    position: relative;
}

.shortcut-hint {
    background: #2a3b4e;
    color: #b4c2d0;
    padding: 8px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    text-align: center;
    border: 1px solid #3f5570;
    transition: all 0.3s;
    cursor: pointer;
}

.shortcut-hint kbd {
    background: #1e2b3c;
    color: #e6edf5;
    padding: 4px 6px;
    border-radius: 6px;
}

/* 折叠状态下隐藏文本，显示图标 */
.sidebar.collapsed .shortcut-hint .hint-text {
    display: none;
}

.sidebar.collapsed .shortcut-hint .hint-icon {
    display: inline-block;
}

.sidebar.collapsed .shortcut-hint {
    padding: 8px 0;
}

.hint-icon {
    display: none;
    font-size: 1.2rem;
    color: #b4c2d0;
    cursor: pointer;
}

/* 二级分类浮层 */
.subcategory-popup {
    position: absolute;
    left: 100%;
    top: 0;
    background-color: #2C2E2F;
    border: 1px solid #3f5570;
    border-left: none;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-width: 180px;
    z-index: 1050;
    padding: 4px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    display: block;
}

.subcategory-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.subcategory-item {
    padding: 10px 16px;
    cursor: pointer;
    color: #b4c2d0;
    font-size: 13px;
    white-space: nowrap;
    background-color: transparent;
}

.subcategory-item:hover {
    background-color: #2a3b4e;
    color: #e6edf5;
}

/* 右侧主面板 */
.main-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    padding: 24px 32px;
    overflow: hidden;
}

/* 头部 */
.panel-header {
    height: 80px;
    margin: -24px -32px 24px -32px;
    padding: 0 32px;
    background: white;
    border-bottom: 1px solid #eef2f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.collapse-btn {
    background: none;
    border: 1px solid #e0e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: #5f7d9c;
    font-size: 1.2rem;
    transition: all 0.2s;
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn i {
    font-size: 1.2rem;
}

.collapse-btn:hover {
    background: #eef2f6;
    color: #1e3a6b;
}

/* 搜索框 */
.search-container {
    display: flex;
    align-items: center;
    background-color: #f0f4fa;
    border: 1px solid #dde5ef;
    border-radius: 30px;
    height: 40px;
    padding: 0 4px;
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
}

.search-engine-selector {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 8px;
    cursor: pointer;
    border-right: 1px solid #dde5ef;
}

.engine-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.engine-icon i {
    font-size: 1.2rem;
}

.engine-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #dde5ef;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
    min-width: 180px;
    margin-top: 5px;
}

.engine-dropdown.show {
    display: block;
}

.engine-option {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.1s;
}

.engine-option:hover {
    background: #eef2f6;
}

.engine-option .engine-icon-small {
    width: 24px;
    text-align: center;
}

.search-input {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    padding: 0 12px;
    font-size: 0.95rem;
    outline: none;
    color: #1e293b;
}

.search-input::placeholder {
    color: #8fa3bc;
}

.search-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: #5f7d9c;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn i {
    font-size: 1.2rem;
}

.search-btn:hover {
    background: #e2eaf5;
    color: #1e3a6b;
}

.import-btn,
.github-link {
    flex-shrink: 0;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    box-sizing: border-box;
    line-height: 1;
    border: 1px solid #e0e8f0;
    border-radius: 8px;
    transition: all 0.2s;
}

.github-link i {
    font-size: 1.2rem;
}

.github-link:hover {
    background: #eef2f6;
    color: #1e3a6b;
}

.github-link {
    color: #5f7d9c;
    text-decoration: none;
    font-size: 0.9rem;
}

.import-btn {
    background: none;
    cursor: pointer;
    color: #5f7d9c;
    font-size: 0.9rem;
}

.import-btn i {
    font-size: 1rem;
}

.import-btn:hover,
.github-link:hover {
    background: #eef2f6;
    color: #1e3a6b;
}

.import-btn i,
.github-link i {
    margin-right: 6px;
}


/* 卡片网格容器 */
.bookmark-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 4px 20px;
}

/* 分类区块 */
.category-section {
    width: 100%;
    margin-bottom: 15px;
}

.category-section-title {
    font-size: 17px;
    font-weight: 400;
    color: rgb(85, 85, 85);
    margin: 0 0 5px 0;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
}

.category-section-title i {
    margin-right: 8px;
    font-size: 17px;
    color: rgb(85, 85, 85);
}

/* 卡片样式 */
.card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    transition: all 0.15s;
    cursor: pointer;
    margin-bottom: 20px;
    position: relative;
}

.card:hover {
    box-shadow: 0 8px 20px rgba(0,20,50,0.08);
    border-color: #d0e0f0;
}

.card-body {
    padding: 16px 18px;
    display: flex;
    gap: 14px;
    align-items: center;
}

.card-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.card-icon i {
    font-size: 16px;
}

.card-icon img {
    max-width: 16px;
    max-height: 16px;
    object-fit: contain;
}

.card-content {
    flex: 1;
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}



.card-description {
    font-size: 13px;
    color: rgb(151, 152, 152);
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 13px;
    cursor: pointer;
    color: #9bb1cc;
    padding: 8px 10px;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 10;
    line-height: 1;
}

.card:hover .edit-btn {
    opacity: 1;
}

.edit-btn:hover {
    background: #eef2f6;
    color: #1e3a6b;
}

/* Toast 提示 */
.card-toast {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e2b3c;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
    pointer-events: none;
    border: 1px solid #3f5570;
}

.card-toast::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid #1e2b3c;
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.1));
    z-index: 101;
}

.card:hover .card-toast {
    opacity: 1;
    visibility: visible;
}

/* 自定义图标选择器样式 */
.custom-icon-selector {
    position: relative;
    width: 100%;
    margin-bottom: 8px;
}

.selected-icon {
    border: 2px solid #dde5ef;
    border-radius: 20px;
    padding: 10px 16px;
    background: #f9fcff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
}

.selected-icon-preview {
    display: flex;
    align-items: center;
    margin-right: 8px;
    width: 24px;
    justify-content: center;
}

.selected-icon-preview i {
    font-size: 1.2rem;
}

.selected-icon-text {
    flex: 1;
    color: #1e293b;
}

.caret {
    font-size: 0.8rem;
    color: #5f7d9c;
    transition: transform 0.2s;
}

.caret.open {
    transform: rotate(180deg);
}

.icon-dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dde5ef;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    margin-top: 4px;
    padding: 16px;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.icon-dropdown-panel.show {
    display: block;
}

.icon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.icon-column {
    display: flex;
    flex-direction: column;
}

.column-header {
    font-weight: 600;
    font-size: 0.9rem;
    color: #3e5670;
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eef2f6;
}

.icon-option {
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #1e293b;
}

.icon-option:hover {
    background: #eef2f6;
}

.icon-option i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.custom-icon-input {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    border-top: 1px solid #eef2f6;
    padding-top: 16px;
}

.custom-icon-input input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #dde5ef;
    border-radius: 20px;
    outline: none;
    font-size: 0.9rem;
}

.custom-icon-input button {
    padding: 8px 16px;
    background: #1e3c72;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.custom-icon-input button:hover {
    background: #143157;
}

#categoryManageModal .card {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* 移除新增分类按钮的下划线 */
#toggleAddCategoryBtn {
    text-decoration: none;
    border: none;
    background: none;
    color: #1e3c72; /* 保持与主题色一致 */
}

#toggleAddCategoryBtn:hover,
#toggleAddCategoryBtn:focus {
    text-decoration: none;
    outline: none;
}

/* 新增分类表单内容居中（按钮本身宽度自适应） */
#addCategoryForm .card-body {
    text-align: center; /* 让内部元素居中 */
}

#addCategoryForm .form-label,
#addCategoryForm .form-control,
#addCategoryForm .form-select {
    text-align: left;   /* 标签和输入框内容左对齐（更符合阅读习惯） */
    width: 90%;         /* 宽度设为90%，并居中 */
    margin-left: auto;
    margin-right: auto;
}

#addCategoryForm .btn {
    width: auto;        /* 按钮宽度自适应 */
    margin-top: 32px;
}

/* 使卡片头部显示手形，且有轻微的悬停反馈 */
#categoryManageModal .card-header {
    cursor: pointer;
    user-select: none;
}

#categoryManageModal .card-header:hover {
    background-color: #f0f4fa; /* 与原头部背景协调 */
}

#categoryListContainer td: nth-child(4) {
    text-align: center;
}

.form-label {
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6c757d;
    color: white;
    font-size: 12px;
    cursor: help;
    margin-left: 4px;
    position: relative;
    flex-shrink: 0;
}
.info-icon:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    margin-bottom: 5px;
}

.priority-input {
    width: 80px !important;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;               /* 移除左右内边距 */
    gap: 0;                    /* 移除弹性项目间隙 */
}

.sidebar.collapsed .sidebar-header .logo {
    margin-right: 0;           /* 移除可能的外边距 */
}

/* 确保折叠时标题已隐藏（通常已有） */
.sidebar.collapsed .sidebar-header .title {
    display: none;
}

.icon-suggestions {
    position: absolute;
    top: 100%;          /* 紧贴输入框底部 */
    left: 0;
    right: 0;
    z-index: 10;
    background: white;
    border: 1px solid #dde5ef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;    /* 可选，微调间距 */
    padding: 4px 0;
}

.icon-suggestions .suggestion-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.icon-suggestions .suggestion-item:hover {
    background: #eef2f6;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.suggestion-item i {
    width: 20px;            /* 固定图标宽度，确保对齐 */
    text-align: center;
    flex-shrink: 0;
}

.suggestion-class {
    color: #6c757d;
    font-size: 0.8rem;
    white-space: nowrap;
    /* 移除 flex: 1 和 text-align，让类名自然左对齐 */
}

.suggestion-item.more-link {
    border-top: 1px solid #dee2e6;
    margin-top: 4px;
    color: #0d6efd;
    font-weight: 500;
}
.suggestion-item.more-link i {
    color: #0d6efd;
}
.private-cell {
    text-align: left;
    vertical-align: middle;
}
#bookmarkModal .modal-footer .form-check {
    margin-bottom: 0;
    line-height: 1.5;
}


/* 内部容器，包裹图标、文字和箭头，并添加下边框 */
.node-inner {
    display: flex;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid #313437;
    padding: 12px 0;        /* 上下内边距 6px */
    gap: 8px;
}


/* 文字自动扩展 */
.node-name {
    flex: 1;
    white-space: nowrap;
}

/* 箭头固定宽度 */
.expand-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #8fa3bc;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.sidebar.collapsed .node-inner {
    justify-content: center;
    gap: 0;
    width: auto;
}

.sidebar.collapsed .node-icon {
    margin-right: 0;
}

/* 卡片标签 */
.card-tags {
    margin-right: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.tag {
    background: #eef2f6;
    color: #1e3a6b;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    cursor: pointer;
    display: inline-block;
    transition: background 0.1s;
    user-select: none;
}
.tag:hover {
    background: #d0e0f0;
}

/* 标题与标签同行布局 */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex-shrink: 0;            /* 标签区域不缩小 */
}
.tag {
    background: #eef2f6;
    color: #1e3a6b;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
    white-space: nowrap;
}
.tag:hover {
    background: #d0e0f0;
}
.card-title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;      /* 改为垂直居中 */
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 !important;
    line-height: 1.5;
}

.card-title {
    font-weight: bold;
    font-size: 13px;
    color: rgb(151, 152, 152);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    line-height: 1.5;         /* 与标签的 line-height 一致，确保对齐 */
    padding-right: 24px;
    margin-bottom: 0;
}

.tag {
    background: #eef2f6;
    color: #1e3a6b;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
    white-space: nowrap;
    line-height: 1.5;         /* 与标题的 line-height 相同 */
}
