:root {
  --bg: #0b101b;
  --card: rgba(21, 28, 43, 0.78);
  --card-solid: #151c2b;
  --card-hover: rgba(30, 41, 63, 0.92);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #eef2f8;
  --muted: #94a3b8;
  --dim: #64748b;
  --accent: #38bdf8;
  --accent-bg: rgba(56, 189, 248, 0.14);
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #f87171;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --card: rgba(255, 255, 255, 0.85);
  --card-solid: #ffffff;
  --card-hover: #ffffff;
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --muted: #475569;
  --dim: #94a3b8;
  --accent: #0284c7;
  --accent-bg: rgba(2, 132, 199, 0.10);
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(600px circle at 15% 10%, rgba(56, 189, 248, 0.14), transparent 60%),
    radial-gradient(520px circle at 85% 20%, rgba(129, 140, 248, 0.12), transparent 60%);
}
[data-theme="light"] .bg-glow {
  background:
    radial-gradient(600px circle at 15% 10%, rgba(56, 189, 248, 0.18), transparent 60%),
    radial-gradient(520px circle at 85% 20%, rgba(99, 102, 241, 0.12), transparent 60%);
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 20px 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex-shrink: 0;
}
.brand-title { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-sub {
  font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.icon-btn, .pill-btn, .small-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.16s ease;
}
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.pill-btn { padding: 6px 14px; font-weight: 500; }
.small-btn { padding: 5px 12px; border-radius: 8px; font-size: 12.5px; }
.icon-btn:hover, .pill-btn:hover, .small-btn:hover { border-color: var(--accent); background: var(--card-hover); }
.small-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.small-btn.primary:hover { background: var(--primary-hover); }
.small-btn.danger { color: var(--danger); }

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
}
.clock-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.clock-time {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}
.greeting { font-size: 15px; font-weight: 600; }
.clock-date { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.search-card {
  width: 100%;
  max-width: 680px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.engine-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.engine-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.engine-tab:hover { color: var(--text); background: var(--accent-bg); }
.engine-tab.active { background: var(--primary); color: #fff; font-weight: 500; }

.search-form { display: flex; gap: 8px; }
.search-input {
  flex: 1;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 14.5px;
  outline: none;
  min-width: 0;
}
.search-input:focus { border-color: var(--accent); }
.search-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0 20px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.search-btn:hover { background: var(--primary-hover); }

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.admin-bar-left, .admin-bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-badge {
  font-size: 12px;
  color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.note-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.note-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: var(--muted); margin-bottom: 8px;
}
.note-state { font-size: 11.5px; color: var(--accent); }
.note-textarea {
  width: 100%;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  outline: none;
}
.note-textarea:focus { border-color: var(--accent); }

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.group-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.group-tab {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.group-tab:hover { color: var(--text); border-color: var(--border-strong); }
.group-tab.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.bookmark-filter {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  width: 190px;
  outline: none;
}
.bookmark-filter:focus { border-color: var(--accent); }

.group-section { margin-bottom: 24px; }
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 650;
}
.group-count { font-size: 12px; color: var(--dim); font-weight: 400; }
.group-ops { display: flex; gap: 6px; }
.mini-op {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.mini-op:hover { color: var(--text); border-color: var(--accent); }
.mini-op.del:hover { color: var(--danger); border-color: var(--danger); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 12px;
}
.link-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 13px;
  text-decoration: none;
  color: var(--text);
  backdrop-filter: blur(12px);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.link-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--card-hover);
}
.link-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  overflow: hidden;
}
.link-icon img { width: 22px; height: 22px; border-radius: 4px; }
.link-info { flex: 1; min-width: 0; }
.link-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-desc {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-admin-ops {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity 0.15s;
}
.link-card:hover .card-admin-ops { opacity: 1; }
.card-op-btn {
  border: 1px solid var(--border);
  background: var(--card-solid);
  color: var(--muted);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.card-op-btn:hover { color: var(--text); border-color: var(--accent); }
.card-op-btn.del:hover { color: var(--danger); border-color: var(--danger); }

.empty-msg {
  text-align: center; color: var(--muted);
  padding: 48px 16px; font-size: 14px;
}

.footer {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--dim);
}

/* Modal */
.modal-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-box {
  width: 100%; max-width: 440px;
  background: var(--card-solid);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13.5px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast-root {
  position: fixed; bottom: 20px; right: 20px; z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--card-solid);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.toast.err { border-color: var(--danger); color: var(--danger); }

@media (max-width: 640px) {
  .brand-sub { display: none; }
  .clock-time { font-size: 34px; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .link-card { padding: 11px 10px; gap: 9px; }
  .link-icon { width: 32px; height: 32px; font-size: 16px; }
  .bookmark-filter { width: 100%; }
  .card-admin-ops { opacity: 1; }
}
