:root {
  --bg: #070b14;
  --bg-soft: rgba(16, 24, 42, 0.72);
  --text: #e8eefc;
  --muted: #93a0c2;
  --line: rgba(255, 255, 255, 0.1);
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.08);
  --accent: #8ab4ff;
  --accent-2: #6d5cff;
  --danger: #ff6b7a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

[data-theme="light"] {
  --bg: #eef2fb;
  --bg-soft: rgba(255, 255, 255, 0.78);
  --text: #162033;
  --muted: #5b6b8a;
  --line: rgba(22, 32, 51, 0.1);
  --card: rgba(255, 255, 255, 0.72);
  --card-hover: #ffffff;
  --shadow: 0 16px 40px rgba(70, 90, 140, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.bg { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
}
.orb-a { width: 420px; height: 420px; left: -80px; top: -60px; background: #3558c7; }
.orb-b { width: 360px; height: 360px; right: -40px; top: 120px; background: #5b3ad6; }
.orb-c { width: 300px; height: 300px; left: 30%; bottom: -80px; background: #1b6b8a; }
[data-theme="light"] .orb { opacity: 0.22; }

.topbar, .wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 12px;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
#clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }

.icon-btn, .text-btn, .fab, .dialog button, .cat-btn, .mini {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(16px);
}
.icon-btn { width: 40px; height: 40px; font-size: 16px; }
.text-btn, .dialog button { padding: 8px 14px; font-size: 14px; }
.text-btn:hover, .icon-btn:hover, .dialog button:hover, .cat-btn:hover, .mini:hover, .fab:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.dialog button[type="submit"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 0;
}
.ghost { background: transparent !important; color: var(--muted) !important; }

.cats { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.cat-btn { padding: 7px 14px; font-size: 13px; }
.cat-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}
.cat-btn .x,
.cat-btn .move {
  margin-left: 6px;
  opacity: 0.75;
}
.cat-btn .move[disabled],
.mini:disabled {
  opacity: 0.28;
  cursor: default;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding-bottom: 28px;
}
.beian {
  text-align: center;
  padding: 8px 16px 28px;
}
.beian a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.beian a:hover {
  color: var(--accent);
  text-decoration: underline;
}
body.editing .beian {
  padding-bottom: 88px;
}
.card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  position: relative;
}
.card:hover {
  transform: translateY(-3px);
  background: var(--card-hover);
  border-color: rgba(138, 180, 255, 0.45);
}
.favicon, .letter {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex: 0 0 40px;
  background: rgba(138, 180, 255, 0.12);
  object-fit: contain;
}
.letter {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
}
.meta { min-width: 0; }
.meta strong { display: block; font-size: 15px; }
.meta span, .empty { color: var(--muted); font-size: 12px; }
.meta strong, .meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-ops {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}
body.editing .card {
  padding-top: 40px;
}
.mini { width: 28px; height: 28px; padding: 0; font-size: 12px; }
.mini.danger:hover { color: var(--danger); border-color: var(--danger); }
.empty { padding: 40px 0; text-align: center; }

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 28px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.55);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 16px;
}
.dialog {
  width: min(420px, 100%);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.dialog label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.dialog input, .dialog select {
  width: 100%;
  margin-top: 6px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #111a2e;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 40;
  font-size: 14px;
}
[data-theme="light"] .toast { background: #162033; }

body.editing .fab { display: grid !important; place-items: center; }

@media (max-width: 680px) {
  .topbar { align-items: flex-start; }
  .brand h1 { font-size: 18px; }
  #clock { display: none; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { flex-direction: column; align-items: flex-start; min-height: 122px; }
}
