:root {
    --bg-color: #f4f6f9;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-secondary: #5f6368;
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --border-color: #e8eaed;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 30px 20px 40px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* 整站低透明度 Logo 背景 */
body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    height: 360px;
    background-image: url('logo.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.06;
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    animation: pageEnter 0.5s ease-out both;
}

@keyframes pageEnter {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ===== Header ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 35px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e1e4e8;
}

/* Logo */
.logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.logo img {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    transition: opacity 0.2s ease;
}

.logo:hover img {
    opacity: 0.85;
}

/* ===== 搜索栏 ===== */
.search-bar {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: flex-start;
    border-radius: 8px;
    transition: box-shadow 0.2s ease;
}

/* 聚焦时在整个搜索栏外围统一加一层 glow，避免子元素交界处重叠 */
.search-bar:focus-within {
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.search-input-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
}

.search-bar textarea {
    flex: 1;
    min-width: 0;
    padding: 10px 36px 10px 14px;
    border: 2px solid #e1e4e8;
    border-right: none;
    border-radius: 8px 0 0 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    min-height: 44px;
    max-height: 160px;
    outline: none;
    background-color: var(--card-bg);
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    resize: none;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    word-break: break-word;
    white-space: pre-wrap;
}

.search-bar textarea::-webkit-scrollbar {
    display: none;
}

/* 清空按钮 */
.search-clear {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    display: none;
    transition: color 0.15s ease;
    z-index: 1;
    border-radius: 3px;
}

.search-clear:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.06);
}

.search-clear.visible {
    display: block;
}

/* 聚焦时只变边框颜色，glow 由父容器统一负责 */
.search-bar:focus-within textarea {
    border-color: var(--primary-color);
}

/* 搜索引擎下拉 */
.search-engine-select {
    padding: 0 26px 0 10px;
    border: 2px solid #e1e4e8;
    border-left: none;
    border-right: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 40px;
    min-height: 44px;
    align-self: stretch;
    outline: none;
    background-color: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* 自定义下拉箭头 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    border-radius: 0;
}

.search-engine-select:hover {
    background-color: #f0f3f7;
    color: var(--text-color);
}

.search-bar:focus-within .search-engine-select {
    border-color: var(--primary-color);
}

/* 搜索按钮 */
.search-btn {
    padding: 0 16px;
    min-height: 44px;
    background-color: var(--primary-color);
    color: white;
    border: 2px solid var(--primary-color);
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    line-height: 40px;
    align-self: stretch;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    flex-shrink: 0;
}

.search-btn:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 2px 6px rgba(74, 144, 226, 0.25);
}

.search-btn:active {
    background-color: #2d6ab5;
    border-color: #2d6ab5;
}

/* ===== Header 按钮容器 ===== */
.header-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* ===== Header 操作按钮 ===== */
.category-manage-btn {
    padding: 10px 18px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.category-manage-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.25);
}

/* ===== 导航区域 ===== */
.category-section {
    margin-bottom: 32px;
}

.category-section.entering {
    animation: sectionEnter 0.4s ease-out both;
}

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

.category-title {
    font-size: 1.05rem;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.02em;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.category-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ===== 折叠按钮 ===== */
.btn-collapse-section {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 10px;
    padding: 2px 5px;
    color: var(--text-secondary);
    transition: color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
    border-radius: 3px;
}

.btn-collapse-section:hover {
    color: var(--primary-color);
    background: rgba(74, 144, 226, 0.08);
}

/* ===== 分类链接数量标签 ===== */
.category-link-count {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
    opacity: 0.6;
    margin-left: auto;
    flex-shrink: 0;
}

/* ===== 折叠状态提示 ===== */
.collapsed-info {
    padding: 14px 18px;
    color: #999;
    font-size: 13px;
    text-align: center;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    background: #fafbfc;
    margin-bottom: 8px;
}

/* ===== 分类拖拽手柄 ===== */
.drag-handle-section {
    cursor: grab;
    color: #bbb;
    font-size: 14px;
    flex-shrink: 0;
    user-select: none;
    letter-spacing: 1px;
    padding: 0 2px;
    transition: color 0.15s ease;
}

.drag-handle-section:active {
    cursor: grabbing;
}

.category-title:hover .drag-handle-section {
    color: #999;
}

/* ===== 分类拖拽状态 ===== */
.category-section.cat-dragging {
    opacity: 0.4;
}

.category-section.cat-drag-over {
    position: relative;
}

.category-section.cat-drag-over::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
    z-index: 1;
    animation: cat-drop-indicator 0.8s ease-in-out infinite;
}

@keyframes cat-drop-indicator {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ===== 分类名称悬浮编辑按钮 ===== */
.category-edit-btn {
    display: inline-block;
    opacity: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    color: #1890ff;
    transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    margin-left: 4px;
    line-height: 1.4;
    vertical-align: middle;
    flex-shrink: 0;
}

.category-title:hover .category-edit-btn {
    opacity: 1;
}

.category-edit-btn:hover {
    background: rgba(24, 144, 255, 0.08);
    border-color: rgba(24, 144, 255, 0.3);
}

/* 分类删除按钮（标题栏悬浮显示） */
.category-delete-btn {
    display: inline-block;
    opacity: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    color: #ff4d4f;
    transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    margin-left: 2px;
    line-height: 1.4;
    vertical-align: middle;
    flex-shrink: 0;
}

.category-title:hover .category-delete-btn {
    opacity: 1;
}

.category-delete-btn:hover {
    background: rgba(255, 77, 79, 0.08);
    border-color: rgba(255, 77, 79, 0.3);
}

/* 分类名称文本 */
.category-name-text {
    display: inline;
}

/* 分类名称内联编辑输入框 */
.category-edit-input {
    font-size: 1.05rem;
    font-weight: 600;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 2px 8px;
    outline: none;
    min-width: 120px;
    background: #fff;
    color: #333;
    font-family: inherit;
}

/* 添加网址弹窗字段 */
.add-url-field {
    margin-bottom: 15px;
}

.add-url-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

/* ===== 卡片拖拽状态 ===== */
.link-card.dragging {
    opacity: 0.35;
    transform: scale(0.97) translateZ(0);
    cursor: grabbing;
}

.link-card.drag-over {
    position: relative;
    box-shadow: 0 2px 0 0 #4a90e2, 0 4px 12px rgba(74, 144, 226, 0.15);
    background: #eef4fd;
    border-radius: 8px;
}

/* ===== 分类区块作为 drop 目标 ===== */
.category-section.drop-zone {
    position: relative;
}

.category-section.drop-zone::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px dashed #4a90e2;
    border-radius: 8px;
    background: rgba(74, 144, 226, 0.04);
    pointer-events: none;
    z-index: 1;
    animation: dropzone-pulse 1.2s ease-in-out infinite;
}

@keyframes dropzone-pulse {
    0%, 100% { border-color: #4a90e2; }
    50%      { border-color: #7ab8f5; }
}

/* ===== 最近访问 ===== */
.recent-section {
    margin-bottom: 24px;
}

.recent-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: clip;
    padding: 6px 0 12px;
    scroll-behavior: smooth;

    scrollbar-width: thin;
    scrollbar-color: #d0d0d0 transparent;
}

.recent-scroll::-webkit-scrollbar {
    height: 4px;
}

.recent-scroll::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 2px;
}

.recent-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.recent-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
    min-width: 110px;
    max-width: 170px;
    padding: 10px 14px;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    position: relative;
}

.recent-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 10px rgba(74, 144, 226, 0.15);
    transform: translateY(-1px);
}

.recent-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    padding: 0;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    color: #999;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.recent-card:hover .recent-delete-btn {
    opacity: 1;
}

.recent-delete-btn:hover {
    background: #ff4d4f;
    color: #fff;
}

.recent-top {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.recent-favicon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border-radius: 2px;
}

.recent-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-domain {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 3px;
    opacity: 0.7;
}

.recent-time {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.55;
    margin-top: 1px;
}

/* ===== 卡片网格 ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

/* ===== 链接卡片 ===== */
.link-card {
    background: var(--card-bg);
    padding: 16px 18px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    cursor: grab;
    transform: translateZ(0);
    will-change: transform;
}

/* 左侧高亮指示器 */
.link-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: transparent;
    transition: background 0.15s ease;
}

.link-card:hover {
    background: #f7f9fc;
}

/* 卡片入场动画 */
.link-card.entering {
    animation: cardEnter 0.4s ease-out both;
    animation-delay: calc(var(--i, 0) * 0.05s);
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(16px) translateZ(0);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

.link-card:hover::before {
    background: var(--primary-color);
}

.link-card a {
    text-decoration: none;
    color: var(--text-color);
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.link-favicon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 4px;
}

/* 默认占位图标（网站无 favicon 时显示）稍淡处理 */
.link-favicon[src^="data:image/svg+xml"] {
    opacity: 0.55;
}

.link-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.link-text {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-text-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.link-url {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.8;
}

/* 连通性指示器 */
.link-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: 4px;
    background-color: #bbb;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* 检测中：呼吸动画 */
.link-status:not([data-status]) {
    animation: connectivity-checking 1.2s ease-in-out infinite;
}

.link-status[data-status="online"] {
    background-color: #52c41a;
    box-shadow: 0 0 4px rgba(82, 196, 26, 0.5);
    animation: connectivity-online 0.4s ease-out;
}

.link-status[data-status="slow"] {
    background-color: #fa8c16;
    box-shadow: 0 0 4px rgba(250, 140, 22, 0.5);
    animation: connectivity-slow 0.4s ease-out;
}

.link-status[data-status="offline"] {
    background-color: #ff4d4f;
    box-shadow: 0 0 4px rgba(255, 77, 79, 0.35);
    animation: connectivity-offline 0.4s ease-out;
}

@keyframes connectivity-checking {
    0%, 100% { opacity: 0.35; transform: scale(0.8); }
    50%      { opacity: 1;    transform: scale(1.2); }
}

@keyframes connectivity-online {
    0%   { transform: scale(0.6); }
    60%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes connectivity-slow {
    0%, 100% { transform: scale(1); }
    25%      { transform: scale(1.3); }
    50%      { transform: scale(0.9); }
    75%      { transform: scale(1.15); }
}

@keyframes connectivity-offline {
    0%, 30%, 60% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-2px); }
    85% { transform: translateX(1px); }
    100% { transform: translateX(0); }
}

/* 标题抓取中：名称下方细进度条 */
.title-loading {
    display: none;
}

.title-loading.active {
    display: block;
    align-self: stretch;
    height: 2px;
    background: linear-gradient(90deg, #4a90e2 30%, #e0e0e0 30%);
    border-radius: 1px;
    animation: title-progress 1.2s ease-in-out infinite;
    margin-top: 2px;
}

@keyframes title-progress {
    0%   { background-position: -100% 0; }
    100% { background-position: 200% 0; }
}

/* 标题更新后文字闪现 */
.title-flash {
    animation: title-flash 0.7s ease-out;
}

@keyframes title-flash {
    0%   { color: #4a90e2; font-weight: 600; }
    100% { color: inherit; font-weight: inherit; }
}

/* 新添加链接的高亮闪烁（滚动定位后短暂高亮） */
.link-highlight {
    animation: link-highlight 2s ease-out;
}

@keyframes link-highlight {
    0%   { box-shadow: 0 0 0 3px rgba(74,144,226,0.5); background: rgba(74,144,226,0.08); }
    30%  { box-shadow: 0 0 0 3px rgba(74,144,226,0.3); background: rgba(74,144,226,0.04); }
    100% { box-shadow: 0 0 0 0px rgba(74,144,226,0); background: transparent; }
}

/* 抓取成功：名称底部绿色下划线 */
.title-loading.done {
    display: block;
    align-self: stretch;
    height: 2px;
    background: #52c41a;
    border-radius: 1px;
    animation: check-pop 0.4s ease-out;
    margin-top: 2px;
}

/* 抓取失败：名称底部红色虚线 */
.title-loading.fail {
    display: block;
    align-self: stretch;
    height: 0;
    border-bottom: 2px dashed #ff4d4f;
    margin-top: 2px;
    animation: fail-shake 0.5s ease-out;
}

@keyframes check-pop {
    0%   { transform: scaleX(0); opacity: 0; }
    60%  { transform: scaleX(1.1); opacity: 1; }
    100% { transform: scaleX(1); opacity: 1; }
}

@keyframes fail-shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-3px); }
    40%      { transform: translateX(3px); }
    60%      { transform: translateX(-2px); }
    80%      { transform: translateX(1px); }
}

/* ===== 卡片操作按钮 ===== */
.card-actions {
    display: flex;
    gap: 6px;
    margin-left: 10px;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.link-card:hover .card-actions {
    opacity: 1;
    pointer-events: auto;
}

.edit-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 7px;
    border-radius: 4px;
    transition: background 0.15s ease, opacity 0.15s ease;
    line-height: 1;
    color: #1890ff;
}

.edit-link-btn:hover {
    background: rgba(24, 144, 255, 0.1);
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    width: 90%;
    max-width: 400px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #e1e4e8;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.close {
    cursor: pointer;
    font-size: 22px;
    color: #999;
    transition: color 0.2s ease;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 22px;
}

.modal-body input,
.modal-body select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

.modal-body input:focus,
.modal-body select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid #e1e4e8;
}

/* ===== 按钮通用 ===== */
.btn-cancel,
.btn-confirm {
    padding: 9px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.btn-cancel {
    background-color: #f0f0f0;
    color: #333;
}

.btn-cancel:hover {
    background-color: #e0e0e0;
}

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

.btn-confirm:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.25);
}

.btn-danger {
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    background-color: #ff4d4f;
    color: white;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.btn-danger:hover {
    background-color: #d9363e;
    box-shadow: 0 2px 8px rgba(255, 77, 79, 0.3);
}

/* 编辑链接模态框字段 */
.edit-link-field {
    margin-bottom: 15px;
}

.edit-link-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

/* ===== 设置中心 ===== */
.category-input-group {
    display: flex;
    gap: 10px;
}

.category-input-group input {
    flex: 1;
}

.btn-small {
    padding: 10px 18px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.btn-small:hover {
    background-color: var(--primary-hover);
}

/* 默认分类徽章（标题栏内） */
.default-badge {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: normal;
}

/* ===== 移动端适配 ===== */
@media (max-width: 640px) {
    body {
        padding: 16px 12px 32px;
    }

    /* 防止 iOS 输入框聚焦时页面自动放大 */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Header 切为 grid：logo + 搜索栏固定第一排，按钮第二排均分 */
    header {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 10px;
    }

    .logo {
        grid-row: 1;
        grid-column: 1;
    }

    /* Logo 缩小 */
    .logo img {
        width: 32px;
        height: 32px;
    }

    .search-bar {
        grid-row: 1;
        grid-column: 2;
        min-width: 0;
    }

    /* 按钮容器跨满两列，内部 flex 均分 */
    .header-actions {
        grid-row: 2;
        grid-column: 1 / -1;
        display: flex;
        gap: 10px;
    }

    .header-actions .category-manage-btn {
        flex: 1;
    }

    .search-bar textarea {
        font-size: 16px;
        min-height: 40px;
        padding: 8px 32px 8px 10px;
        line-height: 1.5;
    }

    .search-engine-select {
        font-size: 16px;
        min-height: 40px;
        line-height: 36px;
        padding: 0 22px 0 6px;
        background-position: right 5px center;
        background-size: 10px;
    }

    .search-btn {
        min-height: 40px;
        line-height: 36px;
        padding: 0 12px;
        font-size: 14px;
    }

    /* 按钮通用移动端样式 */
    .category-manage-btn {
        font-size: 13px;
        padding: 8px 10px;
        text-align: center;
        white-space: nowrap;
    }

    /* 卡片网格缩小 */
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .link-card {
        padding: 12px 14px;
    }

    .link-favicon {
        width: 20px;
        height: 20px;
    }

    .link-text {
        font-size: 13px;
    }

    .link-url {
        font-size: 11px;
    }

    .category-section {
        margin-bottom: 24px;
    }

    .back-to-top {
        bottom: 20px;
        right: 16px;
        width: 40px;
        height: 40px;
        font-size: 18px;
        line-height: 40px;
    }

    .modal-content {
        width: 95%;
        margin: 0 10px;
    }
}

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 30px 0 10px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
}

.footer p {
    margin: 0;
}

/* ===== 返回顶部按钮 ===== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(74, 144, 226, 0.35);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    z-index: 900;
    line-height: 44px;
    text-align: center;
    padding: 0;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 16px rgba(74, 144, 226, 0.45);
    transform: translateY(-2px);
}

.back-to-top:active {
    background: #2d6ab5;
    transform: scale(0.95);
}

/* ===== 懒加载哨兵 ===== */
.lazy-sentinel {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 0;
    min-height: 36px;
}

.lazy-shimmer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 300px;
}

.lazy-shimmer-bar {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        #d0d7de 25%,
        #e8eaed 50%,
        #d0d7de 75%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

.lazy-shimmer-text {
    font-size: 12px;
    color: #b0b8c1;
    letter-spacing: 0.03em;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
