:root {
  --accent: #e60012;
  --tile: clamp(150px, 15vw, 196px);
  --gap: 28px;
  --text: #f5f5f7;
  --muted: rgba(255, 255, 255, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #141416;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: repeating-linear-gradient(
    115deg,
    rgba(255, 255, 255, 0.025) 0px,
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 7px
  );
  z-index: 1;
}

/* ---------- 背景 ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 800px at 30% 18%, rgba(255, 255, 255, 0.06), transparent 62%),
    radial-gradient(900px 700px at 82% 82%, rgba(0, 0, 0, 0.28), transparent 62%),
    linear-gradient(160deg, #232326, #101012);
  background-position: center;
  background-size: cover;
  transition: opacity 0.35s ease;
}

.bg.has-image {
  filter: brightness(0.45) saturate(1.15);
}

.bg-tint {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #1a1a1c;
  opacity: 0;
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 0%, rgba(0, 0, 0, 0.85) 46%, transparent 78%);
  mask-image: radial-gradient(ellipse at 50% 45%, #000 0%, rgba(0, 0, 0, 0.85) 46%, transparent 78%);
}

.bg-tint.active {
  opacity: 0.32;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 30%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.5));
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 76px;
  padding: 0 34px;
  display: flex;
  align-items: center;
  z-index: 30;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, #ff4d5e, #b3000e);
  box-shadow: 0 4px 12px rgba(230, 0, 18, 0.4);
}

.profile-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.6px;
  opacity: 0.94;
}

.top-center {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  max-width: 52vw;
  text-align: center;
  pointer-events: none;
}

.selected-title {
  font-size: clamp(20px, 2.2vw, 30px);
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-title.visible {
  opacity: 1;
  transform: translateY(0);
}

.status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.16s ease, transform 0.16s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

/* ---------- 主体 ---------- */

.stage {
  position: fixed;
  inset: 76px 0 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 10;
}

.rail-viewport {
  position: relative;
  width: 100%;
  height: calc(var(--tile) + 100px);
}

.rail {
  position: absolute;
  top: 50%;
  left: 0;
  display: flex;
  gap: var(--gap);
  padding: 0 12px;
  transform: translate3d(0, -50%, 0);
  transition: transform 0.56s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.rail.no-anim {
  transition: none !important;
}

.tile {
  position: relative;
  flex: none;
  width: var(--tile);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  background: #2a2a2e;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.45);
  transform: translate3d(0, 0, 0);
  transform-origin: 50% 58%;
  transition:
    transform 0.46s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.38s ease,
    border-color 0.22s ease;
  outline: none;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

.tile.near {
  transform: translate3d(0, 2px, 0) scale(0.95);
  opacity: 0.84;
}

.tile.far {
  transform: translate3d(0, 7px, 0) scale(0.89);
  opacity: 0.58;
}

.tile:hover:not(.selected) {
  border-color: rgba(255, 255, 255, 0.42);
}

.tile.near:hover {
  transform: translate3d(0, -1px, 0) scale(0.97);
}

.tile.far:hover {
  transform: translate3d(0, 4px, 0) scale(0.91);
}

.tile.selected {
  transform: translate3d(0, -8px, 0) scale(1.15);
  border-color: #fff;
  box-shadow:
    0 26px 50px rgba(0, 0, 0, 0.65),
    0 0 0 8px rgba(255, 255, 255, 0.07);
  z-index: 5;
  opacity: 1;
}

.tile:focus-visible {
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.glyph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: clamp(46px, 5vw, 64px);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 8px 10px;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.18s ease;
}

.tile.selected .label {
  opacity: 0;
}

.tile.add {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.tile.add .plus {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 56px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.8);
}

.tile.add .label {
  opacity: 1;
}

.edit-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.6px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- 底栏 ---------- */

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  padding: 0 34px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  z-index: 30;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

.editing-badge {
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--accent);
  font-size: 12px;
  letter-spacing: 1px;
  box-shadow: 0 4px 14px rgba(230, 0, 18, 0.35);
}

/* ---------- 编辑工具条 ---------- */

.edit-toolbar {
  position: fixed;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(18, 18, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  z-index: 40;
}

.pill {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.16s ease;
}

.pill:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ---------- 编辑弹窗 ---------- */

dialog {
  width: min(560px, 92vw);
  padding: 0;
  border: none;
  border-radius: 16px;
  background: #242428;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
}

dialog form {
  padding: 26px 26px 20px;
}

dialog h2 {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 700;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  flex: 1;
}

.field label {
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--muted);
}

input[type="text"],
input[type="url"],
input[type="color"],
input:not([type]) {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #3a3a40;
  background: #17171a;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.16s ease;
}

input:focus {
  border-color: var(--accent);
}

input[type="color"] {
  width: 96px;
  padding: 3px;
  height: 40px;
  cursor: pointer;
}

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

.row input {
  flex: 1;
}

.row2 {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  white-space: nowrap;
  cursor: pointer;
}

.check input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.preview {
  margin-top: 8px;
  height: 110px;
  border-radius: 8px;
  border: 1px dashed #3a3a40;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  background: #1b1b1e;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.spacer {
  flex: 1;
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #ff1a2c;
}

.btn.ghost {
  background: transparent;
  border-color: #3f3f46;
  color: #ddd;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn.danger {
  background: transparent;
  border-color: #7f1d1d;
  color: #f87171;
}

.btn.danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

[hidden] {
  display: none !important;
}

/* ---------- 响应式 ---------- */

@media (max-width: 760px) {
  :root {
    --tile: clamp(118px, 30vw, 158px);
    --gap: 18px;
  }

  .topbar {
    height: 64px;
    padding: 0 18px;
  }

  .stage {
    inset: 64px 0 64px;
  }

  .profile-name {
    display: none;
  }

  .top-center {
    top: 12px;
    max-width: 46vw;
  }

  .selected-title {
    font-size: 18px;
  }

  .bottombar {
    padding: 0 18px;
    height: 56px;
  }

  .hint {
    font-size: 11px;
  }

  .edit-toolbar {
    top: 74px;
    gap: 4px;
    padding: 6px;
  }

  .pill {
    padding: 6px 10px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail,
  .tile,
  .selected-title,
  .bg {
    transition: none;
  }
}
