:root {
  --bg: #000000;
  --card: #0d0d0f;
  --card-hover: #141418;
  --fg: #ffffff;
  --muted: #9a9aa3;
  --border: rgba(255, 255, 255, 0.12);
  --primary: #6b5ce7;
  --pink: #d4a5a5;
  --radius: 0.625rem;
  --ease-expo-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body { overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.grain {
  position: fixed;
  inset: 0;
  /* canvas 是 replaced element：inset:0 不会定义它的尺寸，
     必须显式给 width/height，否则会按 intrinsic size（JS 写入的
     innerWidth/innerHeight）参与布局，造成横向溢出。 */
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
}

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

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ── 头部 ─────────────────────────────────────── */
header {
  padding: 72px 0 40px;
  text-align: center;
}
.brand {
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  margin-top: 18px;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #6b5ce7, #d4a5a5, #e6b89c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub { margin-top: 14px; color: var(--muted); font-size: 15px; }

/* ── 分区切换 ─────────────────────────────────── */
.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 36px 0 40px;
  flex-wrap: wrap;
}
.tab {
  border: 0.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 9px 20px;
  border-radius: 9999px;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.18s var(--ease-expo-out);
}
.tab:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.28); }
.tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #6b5ce7, #d4a5a5);
  box-shadow: 0 10px 34px rgba(107, 92, 231, 0.35);
}

/* ── 卡片网格 ─────────────────────────────────── */
.section-title {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 40px 0 16px;
}

.grid {
  display: grid;
  /* min(280px, 100%) 避免窄屏（<328px）时网格撑破视口 */
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.3s var(--ease-expo-out),
    background 0.3s var(--ease-expo-out),
    box-shadow 0.3s var(--ease-expo-out);
}
.card:hover {
  transform: translateY(-4px) scale(1.02);
  background: var(--card-hover);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}

.card-head { display: flex; align-items: center; gap: 10px; }
.dot {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 600;
  background: linear-gradient(135deg, #6b5ce7, #d4a5a5);
  color: #fff;
  flex: none;
}
.card h3 { font-size: 16px; font-weight: 600; }
.badge {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 9999px;
  border: 0.5px solid var(--border);
  color: var(--muted);
  flex: none;
}
.card p { color: var(--muted); font-size: 13.5px; flex: 1; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  padding-top: 6px;
  border-top: 0.5px solid var(--border);
}
.card-foot .open { color: #b9b0ff; }

/* ── 详情页 ───────────────────────────────────── */
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.back {
  border: 0.5px solid var(--border);
  background: transparent; color: var(--muted);
  border-radius: 9999px; padding: 7px 16px; font-size: 13px;
  cursor: pointer; font-family: var(--font);
  transition: all 0.18s var(--ease-expo-out);
}
.back:hover { color: var(--fg); border-color: rgba(255,255,255,0.3); }

.preview {
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #060608;
  height: min(70vh, 620px);
}
.preview iframe { width: 100%; height: 100%; border: 0; background: #060608; }

.detail-meta { margin-top: 18px; display: grid; gap: 8px; font-size: 13.5px; color: var(--muted); }
.detail-meta strong { color: var(--fg); font-weight: 500; }

.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn {
  border-radius: 9999px; padding: 10px 22px; font-size: 14px;
  border: 0; cursor: pointer; font-family: var(--font);
  transition: all 0.2s var(--ease-expo-out);
}
.btn-primary {
  background: linear-gradient(135deg, #6b5ce7, #d4a5a5);
  color: #fff;
}
.btn-primary:hover { transform: scale(1.04); box-shadow: 0 12px 40px rgba(107,92,231,0.45); }
.btn-ghost {
  background: transparent; color: var(--fg);
  border: 0.5px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.06); }

/* ── 手机框预览墙 ─────────────────────────────── */
.phone-wall {
  display: grid;
  /* auto-fit 塌缩空列（项目少时居中），minmax 上限防止单个项目被拉满 */
  grid-template-columns: repeat(auto-fit, minmax(200px, 232px));
  gap: 30px 26px;
  justify-content: center;
  margin-top: 6px;
}

@media (max-width: 560px) {
  .phone-wall {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 22px 16px;
  }
}

.phone-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
}

.phone-frame {
  position: relative;
  aspect-ratio: 9 / 19.5;
  background: #000;
  border: 9px solid #17171b;
  border-radius: 36px;
  box-shadow: 0 0 0 1.5px #2e2e36, 0 24px 50px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  transition: transform 0.35s var(--ease-expo-out),
    box-shadow 0.35s var(--ease-expo-out);
}
.phone-item:hover .phone-frame {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 0 0 1.5px #3d3d47, 0 34px 66px rgba(0, 0, 0, 0.78);
}
.phone-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #060608;
  /* 首页为“橱窗”：整块可点，进详情页再交互 */
  pointer-events: none;
}
.phone-notch {
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 76px;
  height: 19px;
  border-radius: 9999px;
  background: #0a0a0c;
  border: 0.5px solid rgba(255, 255, 255, 0.05);
  z-index: 3;
}
.phone-caption { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.phone-caption .name { font-size: 14px; font-weight: 500; }
.phone-caption .meta { font-size: 11.5px; color: var(--muted); }

/* 详情页的手机框（允许交互） */
.preview-phone { max-width: 390px; margin: 0 auto; }
.preview-phone .phone-frame iframe { pointer-events: auto; }

/* ── 顶栏登录入口 ─────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  padding: 18px 24px;
  z-index: 10;
}
.login-entry {
  font-size: 13px;
  padding: 7px 16px;
  border-radius: 9999px;
  border: 0.5px solid var(--border);
  color: var(--muted);
  transition: all 0.2s var(--ease-expo-out);
}
.login-entry:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.3); }
.login-entry.signed {
  color: #b9b0ff;
  border-color: rgba(107, 92, 231, 0.5);
}

/* ── 开屏动效（Intro Cards） ───────────────── */
.intro-hero {
  position: relative;
  width: 100%;
  height: min(78vh, 640px);
  margin: 6px 0 10px;
  overflow: hidden;
  border-radius: 16px;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, rgba(107, 92, 231, 0.10), transparent 72%);
  touch-action: none;
}

.intro-stage { position: relative; width: 100%; height: 100%; }

.intro-card {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -27px;
  margin-top: -58.5px;
  transform-style: preserve-3d;
  perspective: 1000px;
  will-change: transform, opacity;
  cursor: pointer;
}

.intro-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.intro-card-inner.flipped { transform: rotateY(180deg); }

.intro-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
}

.intro-front {
  background: #000;
  border: 5px solid #17171b;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
}
.intro-glyph {
  font-size: 21px;
  font-weight: 600;
  background: linear-gradient(135deg, #6b5ce7, #d4a5a5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro-back {
  background: #0b0b0f;
  border: 1px solid rgba(255, 255, 255, 0.18);
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px;
  text-align: center;
}
.intro-back-kicker {
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #6b8cff;
}
.intro-back-title { font-size: 9px; font-weight: 500; color: #fff; line-height: 1.2; }
.intro-back-sub { font-size: 7.5px; color: #9a9aa3; }

.intro-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* ── Coverflow 3D 封面流 ───────────────────── */
.coverflow {
  position: relative;
  height: 535px;
  perspective: 1200px;
  perspective-origin: 50% 45%;
  margin: 8px 0 18px;
  cursor: grab;
  touch-action: pan-y;
}
.coverflow.dragging { cursor: grabbing; }
.cf-card {
  position: absolute;
  left: 50%;
  top: 0;
  width: 196px;
  margin-left: -98px;
  will-change: transform, opacity;
  user-select: none;
}
.cf-card:not(.is-active) .phone-frame { filter: brightness(0.7); }
.cf-card .cf-label {
  margin-top: 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}
.cf-card.is-active .cf-label { color: var(--fg); }
.cf-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, rgba(107, 92, 231, 0.2), #06060a 70%);
}
.cf-icon {
  font-size: 44px;
  font-weight: 600;
  background: linear-gradient(135deg, #6b5ce7, #d4a5a5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── CardStack 扇形卡组 ────────────────────── */
.stack {
  position: relative;
  height: 615px;
  perspective: 1500px;
  perspective-origin: 50% 40%;
  margin: 18px 0 6px;
  touch-action: pan-y;
}
.stack-card {
  position: absolute;
  left: 50%;
  top: 30px;
  width: 244px;
  margin-left: -122px;
  will-change: transform, opacity;
  user-select: none;
}
.stack-card.is-top .phone-frame {
  box-shadow: 0 0 0 1.5px #3d3d47, 0 40px 80px rgba(0, 0, 0, 0.8);
}
.stack-card:not(.is-top) .phone-frame { filter: brightness(0.78) saturate(0.9); }
.stack-card .stack-label {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--fg);
  transition: opacity 0.3s ease;
}
.stack-card .stack-sub {
  margin-top: 3px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  transition: opacity 0.3s ease;
}
/* 只有顶部卡显示文字，避免堆叠时标签重叠 */
.stack-card:not(.is-top) .stack-label,
.stack-card:not(.is-top) .stack-sub { opacity: 0; }
.stack-dots {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
}
.stack-dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: all 0.3s var(--ease-expo-out);
}
.stack-dot.active { width: 22px; background: #b9b0ff; }

#spotlight { position: relative; }
#spotlight::before {
  content: "";
  position: absolute;
  inset: -40px 0 auto 0;
  height: 440px;
  background: radial-gradient(ellipse 60% 50% at 50% 30%, rgba(107, 92, 231, 0.14), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── 其它 ─────────────────────────────────────── */
.empty, .error {
  text-align: center; color: var(--muted);
  padding: 60px 0; font-size: 14px;
}
footer {
  margin-top: 90px; padding: 40px 0 60px;
  border-top: 0.5px solid var(--border);
  text-align: center; color: var(--muted); font-size: 12.5px;
}
footer a { color: #b9b0ff; }
.hidden { display: none; }
