/* 咕宝聚合指南 — 样式 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #f0f4ff 0%, #f8f6ff 50%, #eef3fa 100%);
  min-height: 100vh;
  color: #3a3d66;
}

/* ====== 主页 ====== */
.container { max-width: 1200px; margin: 0 auto; padding: 40px 32px 80px; }

/* Header */
.header { display: flex; align-items: center; gap: 20px; margin-bottom: 36px; }
.logo { font-size: 34px; font-weight: 700; color: #3a3d66; flex-shrink: 0; }
.logo-en { font-size: 16px; font-weight: 400; color: #8899bb; margin-left: 10px; }
.nav-links { flex-shrink: 0; margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-links a { font-size: 14px; color: #c0c8dd; text-decoration: none; }
.nav-links a:hover { color: #5a78dc; }
.theme-toggle, .share-btn { background: none; border: 1px solid #d8ddf0; font-size: 14px; cursor: pointer; padding: 5px 10px; color: #8899bb; border-radius: 16px; transition: all 0.2s; }
.share-btn:hover, .theme-toggle:hover { color: #5a78dc; border-color: #5a78dc; }
.nav-links a {
  border: 1px solid #d8ddf0; padding: 5px 12px; border-radius: 16px; font-size: 14px; color: #8899bb; text-decoration: none; transition: all 0.2s;
}
.nav-links a:hover { color: #5a78dc; border-color: #5a78dc; }

/* 搜索栏 */
.search-wrapper { flex: 1; display: flex; justify-content: center; }
.search-input {
  max-width: 520px; width: 100%; padding: 14px 24px;
  border: 2px solid #d8ddf0; border-radius: 28px; background: #fff;
  box-shadow: 0 2px 16px rgba(80,80,200,0.08);
  font-size: 16px; color: #3a3d66; outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: #5a78dc; }
.search-input::placeholder { color: #aabbcc; }

/* 分类 Tab */
.tabs { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 36px; }
.tab {
  padding: 10px 0; width: calc((100% - 72px) / 7); min-width: 120px; text-align: center;
  border-radius: 20px; border: none; cursor: pointer;
  font-size: 19px; font-weight: 700; background: rgba(0,0,0,0.04); color: #8899bb;
  transition: all 0.2s;
}
.tab:hover { background: rgba(90,120,220,0.1); color: #5a78dc; }
.tab.active { background: #5a78dc; color: #fff; }
.tab-en { font-size: 13px; font-weight: 400; opacity: 0.65; }

/* 链接列表 */
.links-section { }
.section-title { font-size: 14px; color: #667799; margin-bottom: 16px; padding-left: 12px; border-left: 4px solid rgba(90,120,220,0.25); }

/* 链接卡片网格 */
.link-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.link-card {
  display: flex; flex-direction: column;
  padding: 24px; height: 200px;
  background: #fff;
  border-radius: 14px; cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  border-top: 4px solid rgba(90,120,220,0.25);
  transition: all 0.2s;
  text-decoration: none; color: inherit;
  overflow: hidden;
}
.link-card:hover {
  border-top-color: #5a78dc;
  box-shadow: 0 6px 28px rgba(80,80,200,0.14); transform: translateY(-2px);
}
.link-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.link-icon { font-size: 40px; width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.link-icon img { width: 32px; height: 32px; border-radius: 4px; }
.link-name { font-size: 17px; font-weight: 600; color: #3a3d66; }
.link-desc { font-size: 15px; color: #8899bb; text-align: left; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; flex: 1; }
.link-arrow { display: none; }

/* 搜索模式 */
.search-mode .tabs { display: none; }
.search-mode .section-title { display: none; }

/* 空状态 */
.empty-state { text-align: center; padding: 40px 20px; color: #8899bb; font-size: 14px; }

/* 页脚 */
.footer { text-align: center; margin-top: 60px; padding-top: 30px; border-top: 1px solid rgba(0,0,0,0.06); }
.footer p { margin-bottom: 8px; }
.footer-disclaimer { font-size: 12px; color: #aabbcc; }
.footer-bottom { font-size: 13px; color: #8899bb; }
.footer-sep { color: #ccd0dd; }
.footer-link { color: #8899bb; text-decoration: none; font-size: 13px; }
.footer-link:hover { color: #5a78dc; }

/* 广告位 */
.ad-container { max-width: 900px; margin: 0 auto 36px; }
[data-theme="dark"] .ad-container { background: transparent; }

/* 回到顶部 */
.back-to-top {
  position: fixed; bottom: 32px; right: 32px;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: #5a78dc; color: #fff; font-size: 22px;
  cursor: pointer; opacity: 0; pointer-events: none; transition: opacity 0.3s;
  box-shadow: 0 2px 12px rgba(90,120,220,0.3);
}
.back-to-top.show { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: #4a68cc; }

/* ====== 管理后台 ====== */
.admin-body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; }

/* 密码门 */
.password-gate { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.password-box {
  background: #fff; border-radius: 16px; padding: 40px; text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06); width: 360px;
}
.password-box h2 { font-size: 20px; color: #3a3d66; margin-bottom: 20px; }
.password-box input {
  width: 100%; padding: 10px 16px; border: 1px solid #e0e4f0; border-radius: 10px;
  font-size: 15px; outline: none; margin-bottom: 12px;
}
.password-box input:focus { border-color: #5a78dc; }
.password-box button {
  width: 100%; padding: 10px; background: #5a78dc; color: #fff;
  border: none; border-radius: 10px; font-size: 15px; cursor: pointer;
}
.password-error { color: #e05555; font-size: 13px; margin-bottom: 8px; display: none; }

/* 管理主界面 */
.admin-panel { display: none; height: 100vh; }
.admin-header { background: #fff; padding: 12px 20px; border-bottom: 1px solid #f0f0f5; display: flex; justify-content: space-between; align-items: center; }
.admin-header .logo { font-size: 16px; }
.btn-logout { background: none; border: 1px solid #e0e4f0; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; color: #8899bb; }

.admin-body-layout { display: flex; height: calc(100vh - 53px); }

/* 侧边栏 */
.sidebar {
  width: 220px; background: #fff; border-right: 1px solid #f0f0f5;
  padding: 16px 0; display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-title { font-size: 12px; color: #aabbcc; padding: 0 16px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.cat-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; cursor: pointer;
  font-size: 14px; color: #3a3d66; transition: background 0.15s;
}
.cat-item:hover { background: #f8f9ff; }
.cat-item.active { background: rgba(90,120,220,0.08); color: #5a78dc; font-weight: 600; }
.cat-item .cat-count { font-size: 11px; color: #aabbcc; margin-left: auto; }
.cat-item .cat-actions { display: none; gap: 4px; margin-left: 4px; }
.cat-item:hover .cat-actions { display: flex; }
.cat-item:hover .cat-count { display: none; }
.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 13px;
  padding: 2px 4px; border-radius: 4px; color: #8899bb;
}
.btn-icon:hover { background: #f0f0f5; color: #3a3d66; }
.btn-icon.danger:hover { background: #fff0f0; color: #e05555; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid #f0f0f5; }
.btn-add-cat {
  width: 100%; padding: 8px; background: #f0f4ff; color: #5a78dc;
  border: 1px dashed #5a78dc; border-radius: 8px; font-size: 13px; cursor: pointer;
}

/* 右侧内容 */
.main-area { flex: 1; padding: 24px 32px; overflow-y: auto; background: linear-gradient(135deg, #f0f4ff 0%, #f8f6ff 50%, #eef3fa 100%); }
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.main-header h3 { font-size: 18px; color: #3a3d66; }
.main-header span { font-size: 13px; color: #8899bb; }

.link-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: #fff; border-radius: 10px; margin-bottom: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  cursor: grab; transition: opacity 0.15s, box-shadow 0.15s;
}
.link-row:active { cursor: grabbing; }
.link-row.dragging { opacity: 0.4; box-shadow: 0 4px 16px rgba(90,120,220,0.15); }
.link-row.drag-over { box-shadow: 0 0 0 2px #5a78dc, 0 2px 12px rgba(90,120,220,0.15); }
.link-row .drag-handle { color: #ccd0dd; margin-right: 2px; cursor: grab; font-size: 14px; }
.link-row .lr-name { font-weight: 600; font-size: 14px; color: #3a3d66; flex: 1; }
.link-row .lr-url { font-size: 12px; color: #8899bb; flex: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-row .lr-actions { display: flex; gap: 4px; flex-shrink: 0; }

.btn-add-link {
  padding: 10px 20px; background: #5a78dc; color: #fff;
  border: none; border-radius: 8px; font-size: 14px; cursor: pointer; margin-top: 8px;
}

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  justify-content: center; align-items: center; z-index: 100;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 28px; width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}
.modal h4 { font-size: 16px; color: #3a3d66; margin-bottom: 18px; }
.modal label { display: block; font-size: 13px; color: #8899bb; margin-bottom: 4px; margin-top: 12px; }
.modal label:first-of-type { margin-top: 0; }
.modal input, .modal textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #e0e4f0; border-radius: 8px;
  font-size: 14px; outline: none; font-family: inherit;
}
.modal input:focus, .modal textarea:focus { border-color: #5a78dc; }
.modal textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.btn-cancel { padding: 8px 18px; background: #f0f0f5; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; color: #8899bb; }
.btn-save { padding: 8px 18px; background: #5a78dc; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn-delete-confirm { padding: 8px 18px; background: #e05555; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; }

/* 提示消息 */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #3a3d66; color: #fff; padding: 10px 24px; border-radius: 20px;
  font-size: 14px; z-index: 200; opacity: 0; transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* 加载骨架 */
.loading-skeleton { }
.skeleton-tabs { display: flex; gap: 12px; justify-content: center; margin-bottom: 36px; }
.sk-tab {
  width: calc((100% - 72px) / 7); min-width: 120px; height: 52px;
  border-radius: 20px; background: linear-gradient(90deg, #e8ecf5 25%, #f0f2fa 50%, #e8ecf5 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
.skeleton-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.sk-card {
  height: 200px; border-radius: 14px;
  background: linear-gradient(90deg, #e8ecf5 25%, #f0f2fa 50%, #e8ecf5 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 页脚统计 */
.footer-stats { font-size: 15px; color: #5a78dc; font-weight: 600; margin-bottom: 12px; }

/* 关于页面 */
.about-content { max-width: 680px; margin: 0 auto; padding: 20px 0; }
.about-content h2 { font-size: 24px; color: #3a3d66; margin-bottom: 20px; }
.about-content h3 { font-size: 16px; color: #3a3d66; margin: 24px 0 8px; }
.about-content p { font-size: 15px; color: #667799; line-height: 1.7; }
.en-title { font-size: 14px; font-weight: 400; color: #aabbcc; margin-left: 6px; }
.en-text { font-size: 14px; color: #aabbcc !important; margin-top: 2px; }

/* 响应式 */
@media (max-width: 640px) {
  .container { padding: 16px 12px 40px; overflow-x: hidden; }
  .header { flex-direction: column; gap: 10px; align-items: stretch; position: relative; width: 100%; }
  .logo { font-size: 22px; text-align: center; }
  .logo-en { font-size: 13px; display: block; margin-left: 0; }
  .nav-links { margin-left: 0; position: absolute; top: 0; right: 0; }
  .search-wrapper { width: 100%; flex: none; }
  .search-input { width: 100%; max-width: none; box-sizing: border-box; padding: 12px 18px; }
  .tabs { gap: 8px; }
  .tab { padding: 8px 16px; width: auto; min-width: 0; font-size: 16px; border-radius: 20px; }
  .tab-en { font-size: 11px; }
  .link-list { grid-template-columns: 1fr; gap: 10px; }
  .link-card { padding: 18px; }
  .back-to-top { bottom: 20px; right: 16px; width: 36px; height: 36px; font-size: 18px; }
  .admin-body-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; border-right: none; border-bottom: 1px solid #f0f0f5; flex-shrink: 0; }
  .sidebar-title { display: none; }
  .sidebar-footer { display: none; }
  .cat-item { white-space: nowrap; padding: 6px 12px; font-size: 13px; }
  .cat-item .cat-count { display: none; }
  .main-area { padding: 16px; }
  .modal { width: 90%; margin: 0 16px; }
  .skeleton-tabs { gap: 6px; }
  .sk-tab { min-width: 0; height: 38px; border-radius: 14px; }
  .skeleton-cards { grid-template-columns: 1fr; }
  .sk-card { height: 140px; }
  .footer { margin-top: 40px; padding-top: 20px; }
  .footer-disclaimer { font-size: 11px; }
  .footer-bottom { font-size: 12px; }
}

/* ====== 暗色模式 ====== */
[data-theme="dark"] {
  --bg-start: #0f1225;
  --bg-mid: #151832;
  --bg-end: #0d1130;
  --card-bg: #1a1e3a;
  --card-border: rgba(120,140,220,0.12);
  --card-top: rgba(120,140,220,0.3);
  --text-primary: #d0d6f0;
  --text-secondary: #8899bb;
  --text-muted: #667799;
  --shadow: rgba(0,0,0,0.2);
}
[data-theme="dark"] body {
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-end) 100%) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .logo { color: var(--text-primary); }
[data-theme="dark"] .logo-en { color: var(--text-secondary); }
[data-theme="dark"] .search-input {
  background: #1a1e3a; border-color: rgba(120,140,220,0.2); color: #d0d6f0;
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}
[data-theme="dark"] .search-input::placeholder { color: #667799; }
[data-theme="dark"] .search-input:focus { border-color: rgba(120,140,220,0.5); }
[data-theme="dark"] .tab { background: rgba(255,255,255,0.04); color: var(--text-secondary); }
[data-theme="dark"] .tab:hover { background: rgba(120,140,220,0.15); color: #8899dd; }
[data-theme="dark"] .tab.active { background: #5a78dc; color: #fff; }
[data-theme="dark"] .link-card {
  background: var(--card-bg); border-top-color: var(--card-top);
  box-shadow: 0 2px 12px var(--shadow);
}
[data-theme="dark"] .link-card:hover { border-top-color: #5a78dc; box-shadow: 0 6px 28px rgba(80,80,200,0.2); }
[data-theme="dark"] .link-name { color: var(--text-primary); }
[data-theme="dark"] .link-desc { color: var(--text-secondary); }
[data-theme="dark"] .section-title { color: var(--text-secondary); border-left-color: var(--card-top); }
[data-theme="dark"] .empty-state { color: var(--text-secondary); }
[data-theme="dark"] .footer { border-top-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .footer-disclaimer { color: #667799; }
[data-theme="dark"] .footer-bottom { color: var(--text-secondary); }
[data-theme="dark"] .footer-stats { color: #8899dd; }
[data-theme="dark"] .nav-links a { color: var(--text-secondary); }
[data-theme="dark"] .nav-links a:hover { color: #8899dd; }
[data-theme="dark"] .about-content h2 { color: var(--text-primary); }
[data-theme="dark"] .about-content h3 { color: var(--text-primary); }
[data-theme="dark"] .about-content p { color: var(--text-secondary); }
[data-theme="dark"] .en-text { color: #667799 !important; }
[data-theme="dark"] .en-title { color: #667799; }
[data-theme="dark"] .back-to-top { background: #5a78dc; box-shadow: 0 2px 12px rgba(90,120,220,0.4); }
[data-theme="dark"] .sk-tab, [data-theme="dark"] .sk-card {
  background: linear-gradient(90deg, #1a1e3a 25%, #22264a 50%, #1a1e3a 75%);
  background-size: 200% 100%;
}
