:root {
  --bg: #0a0e16;
  --panel: rgba(255, 255, 255, .045);
  --panel-solid: #121826;
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #e9eef8;
  --muted: #94a2b8;
  --accent: #6ea8fe;
  --accent-2: #a78bfa;
  --danger: #ff6b6b;
  --ok: #37b24d;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

html { overflow-x: hidden; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.glow {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 60vh;
  background:
    radial-gradient(45% 55% at 30% 20%, rgba(110, 168, 254, .22), transparent 70%),
    radial-gradient(40% 50% at 75% 10%, rgba(167, 139, 250, .18), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(100% - 40px, 980px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(48px, 9vh, 96px) 0 40px;
  display: flex;
  flex-direction: column;
}

/* ---------- 首页 ---------- */

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1 {
  margin: 0;
  font-size: clamp(30px, 5.2vw, 46px);
  line-height: 1.15;
  letter-spacing: -.02em;
  font-weight: 750;
  background: linear-gradient(96deg, #ffffff 10%, #b9cffd 55%, #cbb8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  margin: 12px 0 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 15.5px;
}

.search {
  position: relative;
  margin: 28px 0 30px;
  max-width: 420px;
}

.search input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.search input::placeholder { color: #6e7d93; }

.search input:focus {
  border-color: rgba(110, 168, 254, .55);
  background: rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 4px rgba(110, 168, 254, .12);
}

.search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  translate: 0 -50%;
  width: 16px;
  height: 16px;
  opacity: .5;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 44px;
}

.card {
  --a: var(--accent);
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  transition: transform .16s ease, border-color .16s, background .16s, box-shadow .16s;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: auto -30% -70% auto;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--a) 40%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, .07);
  box-shadow: var(--shadow);
  outline: none;
}

.card:hover::after { opacity: .55; }

.icon {
  flex: 0 0 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 19px;
  line-height: 1;
  background: color-mix(in srgb, var(--a) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--a) 32%, transparent);
  color: #fff;
}

.card-main { min-width: 0; }

.card-title {
  display: block;
  font-weight: 620;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-host {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: #6e7d93;
  letter-spacing: .02em;
}

.empty {
  margin: 40px 0;
  color: var(--muted);
  text-align: center;
}

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: #6e7d93;
  font-size: 12.5px;
}

.admin-link {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: color .15s, border-color .15s;
}

.admin-link:hover { color: var(--text); border-color: var(--border-strong); }

/* 卡片渐入 */
.card { animation: rise .38s backwards; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .card, .card::after, .search input { transition: none; }
}

/* 手机端规则统一放在文件末尾，保证能覆盖前面的基类定义 */

/* ---------- 后台 ---------- */

.admin-wrap {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: 40px 0 80px;
}

.admin-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.admin-head h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.01em;
}

.admin-head a { color: var(--muted); font-size: 13px; }
.admin-head a:hover { color: var(--text); }

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
}

.panel > h2 {
  margin: 0 0 16px;
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

input[type="text"], input[type="password"], input[type="url"], textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, .25);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, textarea:focus {
  border-color: rgba(110, 168, 254, .55);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, .12);
}

textarea { resize: vertical; min-height: 76px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font: inherit;
  font-weight: 560;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}

.btn:hover { background: rgba(255, 255, 255, .1); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, #5b8def, #8b6cf0);
  border-color: transparent;
  color: #fff;
}

.btn.primary:hover { filter: brightness(1.08); }

.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon-btn { padding: 6px 9px; line-height: 1; }
.btn.danger { color: #ffb3b3; border-color: rgba(255, 107, 107, .35); }
.btn.danger:hover { background: rgba(255, 107, 107, .12); }

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.spacer { flex: 1; }

.hint {
  margin: 10px 0 0;
  color: #6e7d93;
  font-size: 12px;
}

/* 链接编辑行 */
.link-list { display: grid; gap: 10px; }

.link-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, .18);
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
}

.link-row.dragging { opacity: .45; }
.link-row.drop-target { border-color: rgba(110, 168, 254, .7); }

.handle {
  align-self: stretch;
  display: grid;
  place-items: center;
  color: #55627a;
  cursor: grab;
  user-select: none;
  border-radius: 8px;
}

.handle:active { cursor: grabbing; }
.handle:hover { color: var(--muted); background: rgba(255, 255, 255, .05); }

.link-fields { display: grid; gap: 8px; }

.link-fields .two {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 8px;
}

.link-fields input { padding: 8px 10px; font-size: 14px; }

.link-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  translate: -50% 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: #1b2436;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: rgba(255, 107, 107, .5); color: #ffc9c9; }
.toast.ok { border-color: rgba(55, 178, 77, .45); }

.gate { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.gate h1 { font-size: 20px; margin: 0 0 6px; }
.gate p { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.gate form { display: grid; gap: 10px; }
.gate .btn { width: 100%; }

.sticky-bar {
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  padding: 14px 0;
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  display: flex;
  gap: 10px;
  align-items: center;
}

.status { font-size: 12.5px; color: #6e7d93; }

/* ---------- 触摸设备 / 窄屏：把点按目标放大到 40px 以上 ---------- */
@media (max-width: 820px), (pointer: coarse) {
  .btn { padding: 11px 16px; }
  .btn.small { font-size: 12px; padding: 10px 8px; min-height: 40px; }
  .btn.small.icon-btn { min-width: 40px; min-height: 40px; font-size: 15px; }
  .link-fields .two { grid-template-columns: 1fr 56px; }
  .swatch { width: 44px; height: 44px; }
  .admin-head a { display: inline-block; padding: 9px 12px; }
  .admin-link { display: inline-block; padding: 9px 14px; }
  .handle { font-size: 18px; }
  .link-row { grid-template-columns: 22px 1fr; gap: 8px; padding: 10px; }
}

/* ---------- 手机：布局 ---------- */
@media (max-width: 560px) {
  .wrap { width: calc(100% - 28px); padding-top: 40px; }
  .grid { grid-template-columns: 1fr; }

  .admin-wrap { width: calc(100% - 24px); padding-top: 28px; }
  .panel { padding: 16px; border-radius: 14px; }
  .admin-head h1 { font-size: 19px; }

  /* 底部操作栏：保存独占一行，其余三等分，避免文字被挤断 */
  .sticky-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px 0;
  }
  .sticky-bar #save-btn { grid-column: 1 / -1; justify-self: stretch; }
  .sticky-bar .spacer { display: none; }
  .toast { bottom: 92px; }
}
