:root {
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius: 16px;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --danger: #e11d48;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f8;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --panel: rgba(255, 255, 255, .62);
  --panel-strong: rgba(255, 255, 255, .9);
  --border: rgba(15, 23, 42, .07);
  --border-strong: rgba(15, 23, 42, .14);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --pill: rgba(99, 102, 241, .08);
  --pill-text: #4338ca;
  --pill-border: rgba(99, 102, 241, .14);
  --link: #6366f1;
  --ai-text: #7c3aed;
  --blob1: rgba(99, 102, 241, .30);
  --blob2: rgba(168, 85, 247, .22);
  --blob3: rgba(6, 182, 212, .22);
  --grid-line: rgba(15, 23, 42, .04);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090b12;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --faint: #64748b;
  --panel: rgba(22, 26, 38, .6);
  --panel-strong: rgba(30, 34, 50, .94);
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --pill: rgba(129, 140, 248, .1);
  --pill-text: #c7d2fe;
  --pill-border: rgba(129, 140, 248, .18);
  --link: #a5b4fc;
  --ai-text: #c4b5fd;
  --blob1: rgba(99, 102, 241, .26);
  --blob2: rgba(168, 85, 247, .16);
  --blob3: rgba(6, 182, 212, .14);
  --grid-line: rgba(255, 255, 255, .03);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }

/* 背景：几团渐变光晕加一层淡网格 */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42vw 42vw at 6% -8%, var(--blob1), transparent 62%),
    radial-gradient(36vw 36vw at 96% 6%, var(--blob2), transparent 62%),
    radial-gradient(48vw 48vw at 62% 112%, var(--blob3), transparent 62%),
    var(--bg);
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse at 50% 0%, #000 25%, transparent 75%);
}

.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 32px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 28px 48px;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 18px; }
.brand-logo {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 6px 18px rgba(99, 102, 241, .4);
}
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 10.5px; font-weight: 600; letter-spacing: 2px; color: var(--faint); }
.gnav-label { padding: 0 10px 6px; font-size: 11.5px; font-weight: 600; color: var(--faint); }
.gnav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.gnav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.gnav-item:hover { background: var(--pill); color: var(--text); }
.gnav-item.active { background: var(--panel-strong); color: var(--text); box-shadow: var(--shadow); }
.gnav-item.drop { outline: 2px dashed #8b5cf6; outline-offset: -2px; }
.gnav-item .dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: hsl(var(--hue) 70% 56%);
  box-shadow: 0 0 0 3px hsl(var(--hue) 70% 56% / .18);
}
.gnav-item .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gnav-item .n { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.side-foot { position: relative; display: flex; gap: 8px; padding-top: 12px; }
.side-btn {
  flex: 1;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.side-btn:hover { color: var(--text); border-color: var(--border-strong); }
#menuBtn { flex: none; width: 36px; }
.menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu button:hover { background: var(--pill); }
.menu .danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
.menu-note { margin: 4px 10px 8px; font-size: 12px; line-height: 1.55; color: var(--muted); }

/* ---------- 顶部 ---------- */
main { min-width: 0; }
.hero { padding: 14px 4px 20px; }
.hero h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(120deg, var(--text) 35%, #8b5cf6 70%, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { margin: 6px 0 0; color: var(--muted); }

.topbar { display: flex; gap: 12px; align-items: center; }
.search { position: relative; flex: 1; }
.search input {
  width: 100%;
  height: 50px;
  padding: 0 48px 0 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, .55);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .15), var(--shadow);
}
.search-icon { position: absolute; z-index: 1; left: 16px; top: 50%; transform: translateY(-50%); display: flex; color: var(--faint); pointer-events: none; }
.search kbd { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); transition: opacity .15s; }
.search input:focus ~ kbd,
.search input:not(:placeholder-shown) ~ kbd { opacity: 0; }
kbd {
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel-strong);
  color: var(--muted);
  font: 600 11px/1 var(--font);
}

.btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { border: 0; color: #fff; background: var(--grad); box-shadow: 0 8px 20px rgba(99, 102, 241, .35); }
.btn.primary:hover { filter: brightness(1.07); box-shadow: 0 10px 26px rgba(99, 102, 241, .45); }
.topbar .btn { height: 50px; padding: 0 22px; border-radius: 14px; }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px 12px 16px;
  border-radius: 14px;
  background: rgba(99, 102, 241, .08);
  border: 1px solid rgba(99, 102, 241, .22);
  font-size: 13px;
}
.banner span { flex: 1; }

/* ---------- 分组 ---------- */
.group { margin-top: 34px; scroll-margin-top: 20px; }
.group-head { display: flex; align-items: center; gap: 10px; min-height: 32px; margin-bottom: 14px; }
.group-head .bar { width: 4px; height: 18px; border-radius: 4px; background: hsl(var(--hue) 70% 56%); }
.group-head h2 {
  margin: 0 0 0 -4px;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 17px;
  font-weight: 700;
  outline: none;
}
.group-head h2[contenteditable="true"] { background: var(--panel-strong); box-shadow: 0 0 0 2px rgba(99, 102, 241, .55); }
.count {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--pill);
  border: 1px solid var(--pill-border);
}
.group-tools { margin-left: auto; display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .15s; }
.group-head:hover .group-tools,
.group-head:focus-within .group-tools { opacity: 1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; border-radius: var(--radius); }
.grid.drop-end { outline: 2px dashed rgba(139, 92, 246, .6); outline-offset: 6px; }

/* ---------- 卡片 ---------- */
.card {
  --hue: 230;
  position: relative;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: grab;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, hsl(var(--hue) 75% 58%), hsl(calc(var(--hue) + 45) 75% 58%));
  opacity: 0;
  transition: opacity .2s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: hsl(var(--hue) 70% 55% / .35);
  box-shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 16px 36px hsl(var(--hue) 70% 45% / .18);
}
.card:hover::before { opacity: 1; }
.filtering .card { cursor: default; }
.card.dragging { opacity: .35; }
.card.drop-before { box-shadow: -4px 0 0 0 #8b5cf6, var(--shadow); }
.card.drop-after { box-shadow: 4px 0 0 0 #8b5cf6, var(--shadow); }
.card.flash { animation: flash 1.8s ease; }
@keyframes flash {
  0%, 45% { box-shadow: 0 0 0 3px rgba(139, 92, 246, .65), var(--shadow); }
  100% { box-shadow: var(--shadow); }
}
.intro .card { animation: rise .55s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 28ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-right: 60px; }
.card-info { min-width: 0; flex: 1; }
.card-title {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 15.5px;
  font-weight: 700;
  text-decoration: none;
}
a.card-title:hover { color: hsl(var(--hue) 70% 52%); }
.card-desc { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12.5px; color: var(--muted); }
.card-actions {
  position: absolute;
  top: 12px;
  right: 10px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .15s, transform .15s;
}
.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; transform: none; }

.logo {
  --hue: 230;
  position: relative;
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(135deg, hsl(var(--hue) 70% 56%), hsl(calc(var(--hue) + 35) 70% 46%));
  box-shadow: 0 4px 12px hsl(var(--hue) 60% 40% / .18);
}
.logo.has-img { background: #fff; border: 1px solid rgba(15, 23, 42, .06); }
.logo img { display: none; width: 26px; height: 26px; object-fit: contain; }
.logo.has-img img { display: block; }
.logo-letter { color: #fff; font-size: 18px; font-weight: 800; }
.logo.has-img .logo-letter { display: none; }

.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links a {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--pill-text);
  background: var(--pill);
  border: 1px solid var(--pill-border);
  text-decoration: none;
  transition: color .15s, background .15s, border-color .15s;
}
.links a:hover { color: #fff; background: hsl(var(--hue) 65% 52%); border-color: transparent; }
.links a.hit { color: #fff; background: var(--grad); border-color: transparent; }
.ai-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: linear-gradient(var(--panel-strong), var(--panel-strong)) padding-box, var(--grad) border-box;
  color: var(--ai-text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, background .15s, box-shadow .15s;
}
.ai-pill:hover { color: #fff; background: var(--grad) border-box; box-shadow: 0 6px 16px rgba(139, 92, 246, .35); }

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.icon-btn:hover { background: var(--pill); color: var(--text); }
.icon-btn.danger:hover { background: rgba(225, 29, 72, .1); color: var(--danger); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--link);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.text-btn:hover { background: var(--pill); }

.empty { padding: 80px 0; text-align: center; color: var(--muted); font-size: 15px; }

/* ---------- 编辑弹窗 ---------- */
dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .3);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}
dialog::backdrop { background: rgba(15, 23, 42, .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog[open] { animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dlg-head h3 { flex: 1; margin: 0; font-size: 16px; }
.dlg-head .logo { width: 40px; height: 40px; }
.dlg-body { max-height: min(64vh, 580px); overflow: auto; padding: 18px 20px 8px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.hint { margin-left: 6px; font-weight: 400; color: var(--faint); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: rgba(99, 102, 241, .6); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(225, 29, 72, .12); }
.textarea { height: auto; padding: 8px 12px; line-height: 1.55; resize: vertical; }
.brief-out { font: 12.5px/1.6 ui-monospace, "Cascadia Code", Consolas, "Microsoft YaHei", monospace; white-space: pre; overflow: auto; }
dialog.wide { width: min(780px, calc(100vw - 32px)); }
.dlg-title { flex: 1; min-width: 0; }
.dlg-title h3 { margin: 0; font-size: 16px; }
.dlg-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }
.link-row { display: grid; grid-template-columns: 130px 1fr auto auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.error { min-height: 1.4em; margin: 0 0 6px; color: var(--danger); font-size: 13px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: #111827;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast button {
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  color: #c7d2fe;
  font-weight: 600;
  cursor: pointer;
}
.toast button:hover { background: rgba(255, 255, 255, .2); }

/* ---------- 适配 ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 12px; padding: 12px 14px 40px; }
  .sidebar { position: static; height: auto; }
  .gnav { flex-direction: row; overflow-x: auto; }
  .gnav-item { white-space: nowrap; }
  .gnav-item .n { margin-left: 4px; }
  .hero h1 { font-size: 24px; }
  .topbar .btn span { display: none; }
  .row2 { grid-template-columns: 1fr; }
  .link-row { grid-template-columns: 90px 1fr auto auto; }
}
@media (hover: none) {
  .card-actions, .group-tools { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
