:root {
  --bg: #f4f6fb;
  --glow-1: rgba(99, 102, 241, .22);
  --glow-2: rgba(14, 165, 233, .18);
  --glow-3: rgba(168, 85, 247, .14);
  --card: rgba(255, 255, 255, .72);
  --card-border: rgba(15, 23, 42, .06);
  --text: #0f172a;
  --muted: #64748b;
  --tile-hover: rgba(79, 70, 229, .08);
  --input: #fff;
  --input-border: rgba(15, 23, 42, .1);
  --accent: #4f46e5;
  --accent-2: #0ea5e9;
  --danger: #e11d48;
  --shadow: 0 10px 30px -18px rgba(30, 41, 99, .35);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1f;
    --glow-1: rgba(79, 70, 229, .28);
    --glow-2: rgba(14, 165, 233, .16);
    --glow-3: rgba(147, 51, 234, .16);
    --card: rgba(15, 23, 42, .62);
    --card-border: rgba(148, 163, 184, .12);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --tile-hover: rgba(129, 140, 248, .12);
    --input: rgba(30, 41, 59, .85);
    --input-border: rgba(148, 163, 184, .2);
    --shadow: 0 10px 30px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(50vmax 50vmax at 5% -10%, var(--glow-1), transparent 60%),
    radial-gradient(40vmax 40vmax at 100% 0%, var(--glow-2), transparent 60%),
    radial-gradient(50vmax 50vmax at 70% 120%, var(--glow-3), transparent 60%);
}
a { color: inherit; }
button { font: inherit; color: inherit; }

/* 顶栏：时钟 + 编辑按钮 */
.top {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.time { font-size: 40px; font-weight: 700; letter-spacing: .02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.date { color: var(--muted); font-size: 14px; margin-top: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status { font-size: 13px; color: var(--muted); }
.status.ok { color: #059669; }
.status.err { color: var(--danger); }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--muted);
  transition: color .15s, transform .15s;
}
.icon-btn:hover { color: var(--accent); transform: rotate(30deg); }

main { max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }

/* 搜索 */
.search { margin: 28px auto 32px; max-width: 680px; }
.engines { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.engine {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}
.engine[aria-selected="true"] { background: var(--card); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
.search-box { position: relative; }
.search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); }
#q {
  width: 100%;
  height: 54px;
  padding: 0 20px 0 50px;
  border-radius: 16px;
  border: 1px solid var(--input-border);
  background: var(--input);
  color: var(--text);
  font-size: 16px;
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99, 102, 241, .18), var(--shadow); }

/* 分组与链接 */
.groups { display: grid; gap: 18px; }
.loading, .empty { text-align: center; color: var(--muted); }
.group {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 14px 10px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.group-head { display: flex; align-items: center; gap: 8px; padding: 0 6px 8px; }
.group-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.group-tools { margin-left: auto; display: none; gap: 4px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 4px; }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 10px;
  border-radius: 14px;
  text-decoration: none;
  min-width: 0;
  transition: background .15s, transform .15s;
}
.tile:hover { background: var(--tile-hover); transform: translateY(-2px); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: #fff;
  box-shadow: 0 4px 12px -6px rgba(15, 23, 42, .35);
  overflow: hidden;
  flex: none;
}
.ico img { width: 28px; height: 28px; object-fit: contain; }
.ico.letter { color: #fff; font-weight: 700; font-size: 18px; }
.name { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 编辑模式 */
.edit-bar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  margin: -12px 0 18px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: 13px;
  color: var(--muted);
}
.edit-bar[hidden] { display: none; }
.edit-bar-actions { display: flex; gap: 8px; }
.btn {
  border: 1px solid var(--input-border);
  background: var(--input);
  border-radius: 10px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 14px;
}
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .6; cursor: wait; }
.mini {
  border: 1px solid var(--input-border);
  background: var(--input);
  border-radius: 8px;
  width: 26px; height: 26px;
  padding: 0;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.mini.del { color: var(--danger); }
body.editing .group-tools { display: flex; }
body.editing .tile { cursor: pointer; outline: 1px dashed var(--input-border); outline-offset: -3px; }
body.editing .tile:hover { transform: none; }
.tile-tools { display: none; position: absolute; top: 2px; left: 2px; right: 2px; justify-content: space-between; }
body.editing .tile-tools { display: flex; }
.tile-tools .mini { width: 22px; height: 22px; font-size: 12px; border-radius: 6px; }
.tile.add { color: var(--muted); outline: 1px dashed var(--accent) !important; }
.tile.add .ico { background: transparent; box-shadow: none; font-size: 26px; color: var(--accent); }

dialog {
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 22px;
  width: min(440px, calc(100vw - 32px));
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog h3 { margin: 0 0 12px; }
dialog label { display: block; margin: 10px 0; font-size: 14px; color: var(--muted); }
dialog input {
  display: block; width: 100%; margin-top: 4px;
  height: 40px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--input-border);
  background: var(--input); color: var(--text); font-size: 15px;
}
dialog ol { padding-left: 20px; font-size: 14px; }
dialog code { font-size: 13px; }
dialog .hint { font-size: 12px; color: var(--muted); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }

.foot { text-align: center; padding: 0 16px 28px; font-size: 12px; color: var(--muted); }
.foot a { text-decoration: none; }

@media (max-width: 560px) {
  .top { padding-top: 18px; }
  .time { font-size: 32px; }
  .search { margin: 18px auto 22px; }
  #q { height: 48px; font-size: 16px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .group { padding: 12px 8px 6px; border-radius: 18px; }
  .ico { width: 40px; height: 40px; }
}
