/* 我的导航 · 书签管理 — 浅色 / 深色，响应式，无外部依赖 */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #17203a;
  --muted: #6b768e;
  --border: #e2e7f0;
  --accent: #4f7cff;
  --accent-2: #7c5cff;
  --accent-soft: #e8efff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #15803d;
  --ok-bg: #e6f7ec;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --shadow: 0 6px 24px rgba(23, 32, 58, .08);
  --shadow-sm: 0 2px 8px rgba(23, 32, 58, .07);
  --radius: 14px;
  --radius-sm: 10px;
}
html[data-theme="dark"] {
  --bg: #0e1220;
  --surface: #171c2e;
  --surface-2: #20263c;
  --text: #eef1f8;
  --muted: #9aa3b8;
  --border: #2a3049;
  --accent: #7ea0ff;
  --accent-2: #a78bff;
  --accent-soft: #24304f;
  --danger: #ff7a7e;
  --danger-soft: #3a1e22;
  --ok: #4ade80;
  --ok-bg: #12351f;
  --warn: #fbbf24;
  --warn-bg: #3a2c10;
  --bad: #f87171;
  --bad-bg: #3a1e22;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 46px; height: 46px; display: grid; place-items: center; flex: none;
  font-size: 24px; border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-sm);
}
.brand h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: .5px; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search-wrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 12px; min-width: min(340px, 72vw);
}
.search-wrap input {
  border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 14px;
}
.search-icon { color: var(--muted); }

/* 按钮 */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; width: 100%; text-align: left; border-radius: var(--radius-sm); }
.btn.danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  width: 28px; height: 28px; border-radius: 8px; font-size: 14px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* 统计条 */
.stats-bar {
  display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: center;
  padding: 12px 22px; font-size: 14px; color: var(--muted);
}
.stat strong { font-size: 20px; color: var(--text); margin-right: 4px; }
.stat-note { margin-left: auto; font-weight: 600; color: var(--text); }
.health-summary { font-weight: 700; color: var(--text); }
.health-time { font-size: 12px; }

/* 测速徽章 */
.health-badge {
  display: inline-block; margin: 10px 0 0 6px; font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 2px 9px; vertical-align: middle;
}
.health-badge.online { color: var(--ok); background: var(--ok-bg); }
.health-badge.slow { color: var(--warn); background: var(--warn-bg); }
.health-badge.offline { color: var(--bad); background: var(--bad-bg); }
.health-badge.checking { color: var(--muted); background: var(--surface-2); }

/* 布局 */
.layout {
  display: grid; grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px; padding: 4px 22px 22px; max-width: 1280px; margin: 0 auto;
  align-items: start;
}
.sidebar {
  position: sticky; top: 86px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.sidebar-head h2, .sidebar-tools h3 { margin: 0; font-size: 15px; }
.cat-list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.cat-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 11px; border-radius: 10px; font-size: 14px;
}
.cat-item:hover { background: var(--surface-2); }
.cat-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cat-item .count {
  font-size: 12px; color: var(--muted); background: var(--surface-2);
  border-radius: 999px; padding: 1px 8px;
}
.cat-item.active .count { background: var(--surface); color: var(--accent); }
.sidebar-tools { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; display: grid; gap: 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

/* 内容区 */
.content { min-width: 0; }
.chip-row { display: none; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px;
}
.card {
  position: relative; display: block; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.card.dragging { opacity: .45; }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.favicon {
  width: 40px; height: 40px; flex: none; border-radius: 10px; object-fit: contain;
  background: var(--surface-2); border: 1px solid var(--border); padding: 4px;
}
.fallback-icon {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-size: 19px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.card-name { font-size: 16px; font-weight: 700; margin: 0; word-break: break-all; }
.card-domain { font-size: 12px; color: var(--muted); margin: 2px 0 0; word-break: break-all; }
.card-notes { font-size: 13px; color: var(--muted); margin: 10px 0 0; min-height: 20px; }
.card-tag {
  display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 9px;
}
.card-actions {
  position: absolute; top: 10px; right: 10px; display: flex; gap: 2px;
  opacity: 0; transition: opacity .12s ease;
}
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }
.card-actions .icon-btn { background: var(--surface); border: 1px solid var(--border); width: 26px; height: 26px; font-size: 12px; }
.card-move { display: flex; gap: 6px; margin-top: 10px; }
.card-move button {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px;
  font-size: 12px; padding: 3px 9px; color: var(--muted);
}
.card-move button:hover { color: var(--text); border-color: var(--accent); }

/* 空状态 */
.empty {
  text-align: center; padding: 56px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-icon { font-size: 44px; }
.empty h3 { margin: 8px 0 4px; }
.empty p { color: var(--muted); margin: 0 0 16px; }

/* 页脚 */
.footer {
  max-width: 1280px; margin: 0 auto; padding: 0 22px 28px;
  font-size: 12px; color: var(--muted);
}
.footer p { margin: 4px 0; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(10, 14, 30, .55); padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(480px, 100%); max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-card form { display: grid; gap: 12px; margin-top: 14px; }
.modal-card label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; }
.modal-card input[type="text"], .modal-card select {
  width: 100%; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 9px 11px; font-size: 14px; outline: none;
}
.modal-card input:focus, .modal-card select:focus { border-color: var(--accent); }
.req { color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.cat-add-row { display: flex; gap: 8px; margin-top: 14px; }
.cat-add-row input {
  flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 9px 11px; font-size: 14px; outline: none;
}
.cat-manage-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.cat-manage-list li {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 14px;
}
.cat-manage-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-manage-list .btn { width: auto; padding: 4px 10px; font-size: 12px; }

/* 提示 */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); border-radius: 999px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 60;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 响应式 */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 4px 14px 18px; }
  .topbar, .stats-bar { padding-left: 14px; padding-right: 14px; }
  .sidebar { position: static; }
  .sidebar-tools { display: none; }
  .chip-row { display: flex; }
  .card-actions { opacity: 1; }
  .stat-note { margin-left: 0; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 12px; }
  .card-notes { display: none; }
  .brand p { display: none; }
}
