/* =========================================================
   mxiao.top — 首页样式
   顶部只放一句话标题，紧接着就是在跑的服务。
   配色跟随系统：默认用 light-dark() 由 prefers-color-scheme 决定，
   手动切换时由 html[data-theme] 改写 color-scheme 覆盖。
   字体：显式命名真实 CJK 字体族，Latin 回退放后面；
   不用负字距、不用半像素字号（避免 CJK 合成假粗与行内抖动）。
   ========================================================= */

:root {
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC",
          "Noto Sans CJK SC", "Microsoft YaHei", -apple-system,
          BlinkMacSystemFont, "Segoe UI", Roboto, "Droid Sans Fallback",
          sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --max: 1180px;
  --pad: 28px;
  --r-lg: 22px;
  --r-md: 16px;

  --c1: #8b7bff;   /* 紫 */
  --c2: #4ed0ff;   /* 青 */
  --c3: #ff7ac6;   /* 粉 */
  --c4: #6ee7a8;   /* 薄荷 */

  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* 颜色全部走 light-dark(明, 暗)，配合 color-scheme 自动生效 */
  --bg: light-dark(#f7f8fb, #06080c);
  --bg-2: light-dark(#ffffff, #0a0d14);
  --panel: light-dark(rgba(255, 255, 255, .74), rgba(255, 255, 255, .035));
  --panel-hi: light-dark(#ffffff, rgba(255, 255, 255, .065));
  --line: light-dark(rgba(15, 22, 40, .10), rgba(255, 255, 255, .09));
  --line-soft: light-dark(rgba(15, 22, 40, .06), rgba(255, 255, 255, .055));
  --fg: light-dark(#0d1220, #eef1f7);
  --fg-2: light-dark(#4c5568, #a9b1c3);
  --fg-3: light-dark(#6b7386, #7d8598);
  --glow: light-dark(rgba(120, 100, 255, .18), rgba(139, 123, 255, .30));
  --shadow-c: light-dark(rgba(24, 32, 60, .38), rgba(0, 0, 0, .92));
  --hover-bg: light-dark(#ffffff, rgba(255, 255, 255, .055));
  --sheen: light-dark(rgba(15, 22, 40, .12), rgba(255, 255, 255, .16));
  --tint: light-dark(rgba(139, 123, 255, .12), rgba(139, 123, 255, .17));
  --grid: light-dark(rgba(15, 22, 40, .028), rgba(255, 255, 255, .035));
  --glow-a: light-dark(rgba(124, 92, 255, .46), rgba(124, 92, 255, .52));
  --glow-b: light-dark(rgba(46, 190, 255, .38), rgba(46, 190, 255, .44));
  --glow-c: light-dark(rgba(255, 106, 190, .30), rgba(255, 106, 190, .34));
  --scrim: light-dark(rgba(20, 26, 44, .34), rgba(4, 6, 12, .60));
}

/* 老浏览器不认 light-dark() 时退到一套固定暗色，不至于白字白底 */
@supports not (color: light-dark(#000, #fff)) {
  :root {
    --bg: #06080c;
    --bg-2: #0a0d14;
    --panel: rgba(255, 255, 255, .035);
    --panel-hi: rgba(255, 255, 255, .065);
    --line: rgba(255, 255, 255, .09);
    --line-soft: rgba(255, 255, 255, .055);
    --fg: #eef1f7;
    --fg-2: #a9b1c3;
    --fg-3: #6f7788;
    --glow: rgba(139, 123, 255, .30);
    --shadow-c: rgba(0, 0, 0, .92);
    --hover-bg: rgba(255, 255, 255, .055);
    --sheen: rgba(255, 255, 255, .16);
    --tint: rgba(139, 123, 255, .17);
    --grid: rgba(255, 255, 255, .05);
    --glow-a: rgba(124, 92, 255, .52);
    --glow-b: rgba(46, 190, 255, .44);
    --glow-c: rgba(255, 106, 190, .34);
    --scrim: rgba(4, 6, 12, .60);
  }
}

html { color-scheme: light dark; }
html[data-theme="dark"]  { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .5s var(--ease), color .5s var(--ease);
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

::selection { background: rgba(139, 123, 255, .38); color: #fff; }

:focus-visible {
  outline: 2px solid var(--c2);
  outline-offset: 3px;
  border-radius: 6px;
}

.tabnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
}

.skip {
  position: fixed;
  top: -60px; left: 16px;
  z-index: 999;
  padding: 10px 16px;
  background: var(--fg);
  color: var(--bg);
  border-radius: 8px;
  transition: top .2s;
}
.skip:focus { top: 12px; }

/* ---------------- 背景 ---------------- */
/* 原来这里有三团 blur(90px) 的彩色光斑，浅色模式下会糊成一片脏粉紫。
   现在换成：干净底色 + 一层极淡的点阵，向下渐隐。颜色交给标题渐变和卡片。 */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
/* 彩色光：纯 radial-gradient 叠出来（不加 blur），颜色干净、不发灰 */
.backdrop::before {
  content: "";
  position: absolute;
  inset: -12% -12% -6%;
  background-image:
    radial-gradient(42% 34% at 10% -2%, var(--glow-a), transparent 72%),
    radial-gradient(40% 32% at 92% 0%, var(--glow-b), transparent 74%),
    radial-gradient(46% 34% at 62% 108%, var(--glow-c), transparent 76%);
  animation: drift 32s var(--ease) infinite alternate;
  will-change: transform;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(1.5%, 1.8%, 0) scale(1.05); }
}
/* 细网格：叠在光上面，往下渐隐 */
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .32) 44%, transparent 66%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .32) 44%, transparent 66%);
}

/* 噪点，让大面积纯色不脏 */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
html[data-theme="light"] .grain { opacity: .022; }

/* ---------------- 导航 ---------------- */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 80;
  border-bottom: 1px solid transparent;
  transition: background .4s var(--ease), border-color .4s var(--ease),
              transform .4s var(--ease);
}
.nav.is-stuck {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom-color: var(--line-soft);
}
.nav.is-hidden { transform: translateY(-102%); }

.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  /* 顶部留白交给浏览器（不用 viewport-fit=cover，避免 env() 在部分引擎里
     把整条 padding 声明作废） */
  padding: 16px var(--pad);
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.brand-mark { width: 26px; height: 26px; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-name { font-size: 17px; font-weight: 600; }

.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.kbd-btn {
  display: inline-flex;
  flex: none;
  white-space: nowrap;
  align-items: center;
  gap: 8px;
  justify-content: center;
  height: 36px;
  padding: 0 10px 0 12px;
  /* 内容约 111px：给个下限，避免某些引擎把图标/kbd 挤出按钮盒 */
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg-2);
  font-size: 13px;
  transition: border-color .25s, color .25s, background .25s;
}
.kbd-btn:hover { color: var(--fg); background: var(--panel-hi); }
.kbd-btn svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round;
}
kbd {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 5px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  color: var(--fg-3);
}

.theme-btn {
  flex: none;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg-2);
  transition: color .25s, background .25s, border-color .25s;
}
.theme-btn:hover { color: var(--fg); background: var(--panel-hi); }
.theme-btn svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.theme-btn .i-sun { display: none; }
html[data-theme="light"] .theme-btn .i-sun { display: block; }
html[data-theme="light"] .theme-btn .i-moon { display: none; }

/* ---------------- 标题 ---------------- */
.stage {
  position: relative;
  z-index: 2;
  padding: 116px 0 40px;
}
.stage-title {
  font-size: clamp(36px, 5.6vw, 76px);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: 0;
  white-space: nowrap;   /* 一行，换行交给字号 clamp */
}
.stage-title .gap { display: inline-block; width: .32em; }
.stage-title .grad {
  background: linear-gradient(102deg, var(--c1) 4%, var(--c2) 46%, var(--c4) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  background-size: 200% 100%;
  animation: sheen 9s var(--ease) infinite alternate;
  white-space: nowrap;
}
@keyframes sheen {
  from { background-position: 0% 50%; }
  to   { background-position: 100% 50%; }
}

/* ---------------- 服务卡片 ---------------- */
.services {
  position: relative;
  z-index: 2;
  padding: 0 0 96px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
/* 服务卡片一律左对齐：最后一行不满 3 张就空在右边，不居中、不拉伸。 */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 22px 20px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  /* 每张卡左上角一抹自己的颜色，整片网格看起来像调色板 */
  background:
    radial-gradient(135% 105% at 0% 0%, var(--wash, transparent) 0%, transparent 62%),
    var(--panel);
  overflow: hidden;
  transition: transform .45s var(--ease-out), border-color .45s,
              background .45s, box-shadow .45s;
  will-change: transform;
}
/* 鼠标跟随的高光 */
.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%),
              var(--tint), transparent 62%);
  opacity: 0;
  transition: opacity .4s;
  pointer-events: none;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(150deg, var(--sheen), transparent 42%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: .55;
  pointer-events: none;
  transition: opacity .4s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--line);
  background: var(--hover-bg);
  box-shadow: 0 24px 52px -30px var(--shadow-c);
}
.card:hover::before { opacity: 1; }
.card:hover::after { opacity: 1; }

/* 图标与 hover 光斑按 4 色轮换，免得八张卡一模一样 */
.cards > .card:nth-child(4n + 1) {
  --accent: var(--c1);
  --wash: light-dark(rgba(124, 92, 255, .15), rgba(124, 92, 255, .20));
  --tint: light-dark(rgba(124, 92, 255, .30), rgba(124, 92, 255, .34));
}
.cards > .card:nth-child(4n + 2) {
  --accent: var(--c2);
  --wash: light-dark(rgba(46, 190, 255, .15), rgba(46, 190, 255, .20));
  --tint: light-dark(rgba(46, 190, 255, .30), rgba(46, 190, 255, .34));
}
.cards > .card:nth-child(4n + 3) {
  --accent: var(--c3);
  --wash: light-dark(rgba(255, 106, 190, .14), rgba(255, 106, 190, .18));
  --tint: light-dark(rgba(255, 106, 190, .28), rgba(255, 106, 190, .32));
}
.cards > .card:nth-child(4n) {
  --accent: var(--c4);
  --wash: light-dark(rgba(110, 231, 168, .16), rgba(110, 231, 168, .18));
  --tint: light-dark(rgba(110, 231, 168, .30), rgba(110, 231, 168, .30));
}
.cards > .card .card-icon { color: var(--accent, var(--c2)); }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: linear-gradient(150deg, var(--tint, var(--panel-hi)), transparent 78%);
  color: var(--c2);
}
.card-icon svg {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.card-no {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: .06em;
}
.card h3 {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}
.card p {
  font-size: 14px;
  line-height: 1.72;
  color: var(--fg-2);
  flex: 1;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
}
.card-foot .go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--fg-2);
  transition: color .3s, gap .3s var(--ease-out);
}
.card-foot .go i { font-style: normal; }
.card:hover .card-foot .go { color: var(--c2); gap: 7px; }

/* ---------------- 页脚 ---------------- */
.footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--line-soft);
  padding: 36px 0 44px;
}
.footer-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.foot-brand p {
  margin-top: 6px;
  font-size: 13px;
  color: var(--fg-3);
}
.foot-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--fg-3);
}
.to-top {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--fg-3);
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  transition: color .3s, border-color .3s, transform .3s;
}
.to-top:hover { color: var(--fg); border-color: var(--line); transform: translateY(-2px); }

/* ---------------- 按钮（404 页也在用） ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: transform .35s var(--ease-out), box-shadow .35s,
              background .35s, border-color .35s, color .35s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  color: #0a0d14;
  background: linear-gradient(100deg, var(--c2), var(--c4));
  box-shadow: 0 14px 34px -16px var(--glow);
}
.btn-primary:hover { box-shadow: 0 18px 40px -14px var(--glow); }
.btn-ghost {
  border-color: var(--line);
  background: var(--panel);
  color: var(--fg-2);
}
.btn-ghost:hover { color: var(--fg); background: var(--panel-hi); border-color: var(--line); }

/* ---------------- 搜索面板 ---------------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 200;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: none;
}
.palette[open] { display: block; }
.palette::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.palette-box {
  position: absolute;
  top: 16vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 40px 90px -34px var(--shadow-c);
  overflow: hidden;
  animation: pop .28s var(--ease-out);
}
@keyframes pop {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.985); }
}
.palette-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.palette-search svg {
  width: 17px; height: 17px;
  fill: none; stroke: var(--fg-3);
  stroke-width: 1.7; stroke-linecap: round;
  flex: none;
}
.palette-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
}
.palette-search input::placeholder { color: var(--fg-3); }

.palette-list {
  max-height: 52vh;
  overflow-y: auto;
  padding: 8px;
}
.palette-list li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--fg-2);
  font-size: 14px;
}
.palette-list li a:hover,
.palette-list li a[aria-selected="true"] {
  background: var(--panel-hi);
  color: var(--fg);
}
.palette-list .p-host {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
}
.palette-list .p-empty {
  padding: 26px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--fg-3);
}
.palette-foot {
  display: flex;
  gap: 18px;
  padding: 11px 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--fg-3);
}
.palette-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------------- 入场动画 ---------------- */
.load {
  opacity: 0;
  transform: translateY(18px);
  animation: rise .95s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 90ms + 60ms);
}
@keyframes rise { to { opacity: 1; transform: none; } }

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .8s var(--ease-out), transform .8s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 70ms);
}
.reveal.is-in { opacity: 1; transform: none; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  :root { --pad: 18px; }

  /* 手机导航收窄：58px 高，顺手把刘海让出来 */
  .nav-inner { padding: 12px var(--pad); gap: 16px; }
  .brand-mark { width: 22px; height: 22px; }
  .brand-name { font-size: 16px; }
  .kbd-btn, .theme-btn { height: 34px; width: 34px; }
  .kbd-btn span, .kbd-btn kbd { display: none; }
  .kbd-btn { min-width: 0; padding: 0; justify-content: center; }
  .kbd-btn svg, .theme-btn svg { width: 16px; height: 16px; }

  /* 标题：58px 导航 + 26px 空隙，避免和图标贴在一起 */
  .stage { padding: 72px 0 22px; }
  .stage-title { font-size: clamp(28px, 8.8vw, 40px); line-height: 1.2; }

  /* 手机：一行两个。宽度够了，描述能放两行，卡片回到"图标 + 标题 + 描述 + host" */
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 14px 13px 12px; gap: 6px; border-radius: 16px; }
  .card-icon { width: 30px; height: 30px; border-radius: 9px; }
  .card-icon svg { width: 16px; height: 16px; }
  .card-no { font-size: 10px; }
  .card h3 {
    margin-top: 2px;
    font-size: 14.5px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .card > p { font-size: 11.5px; line-height: 1.55; }
  .card-foot { margin-top: 6px; padding-top: 7px; font-size: 9.5px; }
  .card-foot .go { display: none; }
  .services { padding-bottom: 56px; }

  .footer { padding: 26px 0 32px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
}

/* 尊重减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .load, .reveal { opacity: 1; transform: none; }
}
