:root {
  --topbar-h: 58px;
  --cream: #fff4dc;
  --cream-2: #f3e3c3;
  --cream-dim: rgba(255, 244, 220, .74);
  --cream-faint: rgba(255, 244, 220, .48);
  --cream-ghost: rgba(255, 244, 220, .14);
  --line: rgba(255, 244, 220, .5);
  --pink: #eba7af;
  --pink-deep: #c9808c;
  --gold: #ffdc93;
  --ink: #26292b;
  --red-dot: #e84732;

  --panel: rgba(16, 22, 25, .55);
  --panel-strong: rgba(13, 18, 21, .74);
  --well: rgba(6, 10, 12, .42);
  --cell: rgba(12, 16, 18, .66);
  --cell-hover: rgba(46, 52, 54, .72);
  --cell-missing: rgba(12, 16, 18, .3);

  --r-cell: 20px;
  --r-panel: 24px;
  --shadow: 0 16px 48px rgba(0, 0, 0, .32);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  --font-num: "Lato", "Segoe UI", "Helvetica Neue", Arial, var(--font);
  --font-mono: "Cascadia Mono", "JetBrains Mono", Consolas, "SFMono-Regular", monospace;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: #172227;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
img.is-broken, img.is-empty { opacity: 0 !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

::selection { background: rgba(255, 220, 160, .35); }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 244, 220, .28) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 244, 220, .26); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 背景：暮色天空 + 光束 + 云海 + 光尘 ---------- */
.sky-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(110% 70% at 50% 115%, rgba(70, 104, 84, .5), transparent 62%),
    radial-gradient(80% 55% at 12% -12%, rgba(255, 228, 188, .2), transparent 62%),
    radial-gradient(70% 50% at 92% 8%, rgba(150, 190, 210, .12), transparent 60%),
    linear-gradient(180deg, #1a2a34 0%, #213540 36%, #25393b 64%, #182224 100%);
}
.sky-bg__glow {
  position: absolute;
  left: 8%;
  top: -18%;
  width: 46vw;
  height: 46vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 238, 205, .16), transparent 66%);
  filter: blur(12px);
}
.sky-bg__rays i {
  position: absolute;
  top: -30%;
  height: 160%;
  transform: rotate(24deg);
  background: linear-gradient(90deg, transparent, rgba(255, 248, 232, .075), transparent);
  filter: blur(10px);
  animation: ray-drift 20s ease-in-out infinite alternate;
}
.sky-bg__rays i:nth-child(1) { left: 20%; width: 16vw; }
.sky-bg__rays i:nth-child(2) { left: 46%; width: 7vw; opacity: .7; animation-duration: 26s; animation-delay: -8s; }
.sky-bg__rays i:nth-child(3) { left: 68%; width: 11vw; opacity: .5; animation-duration: 31s; animation-delay: -14s; }
@keyframes ray-drift {
  from { transform: translateX(-3vw) rotate(24deg); opacity: .55; }
  to { transform: translateX(4vw) rotate(21deg); opacity: 1; }
}
.sky-bg__clouds {
  position: absolute;
  left: -15%;
  right: -15%;
  bottom: -14%;
  height: 48%;
  background:
    radial-gradient(38% 46% at 18% 72%, rgba(226, 236, 240, .11), transparent 70%),
    radial-gradient(34% 42% at 66% 82%, rgba(226, 236, 240, .09), transparent 70%),
    radial-gradient(28% 36% at 44% 96%, rgba(255, 240, 222, .09), transparent 70%),
    radial-gradient(30% 40% at 92% 68%, rgba(226, 236, 240, .07), transparent 70%);
  filter: blur(12px);
  animation: cloud-drift 60s ease-in-out infinite alternate;
}
@keyframes cloud-drift { from { transform: translateX(-2%); } to { transform: translateX(2%); } }
.sky-bg__motes i {
  position: absolute;
  bottom: -12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 246, 226, .9);
  box-shadow: 0 0 10px 3px rgba(255, 232, 190, .45);
  opacity: 0;
  animation: mote-rise linear infinite;
}
.sky-bg__motes i:nth-child(1) { left: 6%; animation-duration: 24s; animation-delay: -2s; }
.sky-bg__motes i:nth-child(2) { left: 14%; animation-duration: 30s; animation-delay: -17s; width: 3px; height: 3px; }
.sky-bg__motes i:nth-child(3) { left: 23%; animation-duration: 21s; animation-delay: -9s; }
.sky-bg__motes i:nth-child(4) { left: 31%; animation-duration: 34s; animation-delay: -24s; width: 5px; height: 5px; }
.sky-bg__motes i:nth-child(5) { left: 42%; animation-duration: 27s; animation-delay: -5s; width: 3px; height: 3px; }
.sky-bg__motes i:nth-child(6) { left: 51%; animation-duration: 23s; animation-delay: -19s; }
.sky-bg__motes i:nth-child(7) { left: 60%; animation-duration: 32s; animation-delay: -12s; width: 3px; height: 3px; }
.sky-bg__motes i:nth-child(8) { left: 68%; animation-duration: 26s; animation-delay: -1s; }
.sky-bg__motes i:nth-child(9) { left: 76%; animation-duration: 29s; animation-delay: -21s; width: 5px; height: 5px; }
.sky-bg__motes i:nth-child(10) { left: 84%; animation-duration: 22s; animation-delay: -14s; }
.sky-bg__motes i:nth-child(11) { left: 91%; animation-duration: 35s; animation-delay: -6s; width: 3px; height: 3px; }
.sky-bg__motes i:nth-child(12) { left: 97%; animation-duration: 25s; animation-delay: -27s; }
@keyframes mote-rise {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: .85; }
  50% { transform: translate(24px, -55vh); }
  88% { opacity: .5; }
  100% { transform: translate(-10px, -108vh); opacity: 0; }
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 clamp(14px, 3vw, 32px);
  background: linear-gradient(180deg, rgba(12, 18, 21, .82), rgba(12, 18, 21, .5));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 244, 220, .1);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cream);
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .06em;
}
.topbar__brand img { width: 26px; height: 26px; filter: drop-shadow(0 0 6px rgba(255, 236, 190, .5)); }
.topbar__nav { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: var(--well); }
.topbar__nav a {
  padding: 5px 18px;
  border-radius: 999px;
  color: var(--cream-dim);
  text-decoration: none;
  font-size: 14px;
  transition: background .2s, color .2s;
}
.topbar__nav a:hover { color: var(--cream); }
.topbar__nav a.is-active { background: var(--cream); color: var(--ink); font-weight: 600; }

.app {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 72px;
}

/* ---------- 通用组件 ---------- */
.sky-panel {
  border-radius: var(--r-panel);
  background: var(--panel);
  border: 1px solid rgba(255, 244, 220, .09);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(112%);
  -webkit-backdrop-filter: blur(16px) saturate(112%);
}

.sky-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .08em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 0 0 0 rgba(255, 236, 190, 0);
  transition: transform .22s var(--ease-spring), box-shadow .22s ease, background .2s;
}
.sky-btn:hover { box-shadow: 0 0 22px rgba(255, 236, 190, .45); }
.sky-btn:active { transform: scale(.96); }
.sky-btn:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.sky-btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.sky-btn--ghost {
  background: rgba(8, 12, 14, .42);
  color: var(--cream);
  box-shadow: inset 0 0 0 1.5px rgba(255, 244, 220, .3);
}
.sky-btn--ghost:hover { background: rgba(255, 244, 220, .1); box-shadow: inset 0 0 0 1.5px rgba(255, 244, 220, .6); }
.sky-btn--sm { min-height: 32px; padding: 0 14px; font-size: 13px; letter-spacing: .04em; }

.sky-input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1.5px solid rgba(255, 244, 220, .2);
  border-radius: 14px;
  background: rgba(6, 10, 12, .5);
  color: var(--cream);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.sky-input::placeholder { color: rgba(255, 244, 220, .36); }
.sky-input:focus { border-color: rgba(255, 244, 220, .75); box-shadow: 0 0 0 4px rgba(255, 244, 220, .09); background: rgba(6, 10, 12, .62); }
.sky-input[type="number"] { -moz-appearance: textfield; appearance: textfield; font-family: var(--font-num); }
.sky-input[type="number"]::-webkit-inner-spin-button,
.sky-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.sky-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--well);
  box-shadow: inset 0 0 0 1px rgba(255, 244, 220, .08);
}
.sky-seg button {
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cream-dim);
  font-size: 13px;
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.sky-seg button:hover { color: var(--cream); }
.sky-seg button.is-active { background: var(--cream); color: var(--ink); font-weight: 600; }
.sky-seg button:focus-visible { outline: 2px solid var(--cream); outline-offset: 1px; }

/* 游戏内物品格子 */
.sky-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: var(--r-cell);
  background: var(--cell);
  box-shadow: inset 0 0 0 2px transparent;
  transition: background .18s, box-shadow .18s, transform .2s var(--ease-spring);
}
.sky-cell > img { width: 74%; height: 74%; object-fit: contain; pointer-events: none; transition: opacity .2s, filter .2s; }
button.sky-cell:hover { background: var(--cell-hover); }
button.sky-cell:active { transform: scale(.95); }
button.sky-cell:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(255, 244, 220, .6); }
.sky-cell.is-selected {
  background: rgba(70, 72, 68, .62);
  box-shadow: inset 0 0 0 2.5px var(--cream), 0 0 14px rgba(255, 240, 210, .18);
}
.sky-cell.is-selected::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 26%;
  height: 11%;
  transform: translateX(-50%);
  background: var(--cream);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.sky-cell.is-missing { background: var(--cell-missing); }
.sky-cell.is-missing > img { opacity: .26; filter: grayscale(1) brightness(.9); }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--cream);
  color: #3a3a3a;
  font: 700 11px/1 var(--font-num);
  letter-spacing: .03em;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .3);
}

.sky-section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  color: var(--cream);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: .06em;
}
.sky-section-title__line { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 244, 220, .5); }
.sky-section-title__extra { color: var(--cream-dim); font-size: 13px; letter-spacing: 0; font-family: var(--font-num); }

/* 可折叠分区标题：整行可点，右侧箭头指示状态 */
.sky-section-title--btn {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.sky-section-title--btn .chevron { opacity: .65; transform: rotate(-135deg) translate(-2px, -2px); transition: transform .2s, opacity .2s; }
.sky-section-title--btn:hover .chevron { opacity: 1; }
.sky-section-title--btn.is-open .chevron { transform: rotate(45deg) translate(-2px, -2px); }
.collapse-block > .sky-section-title--btn { margin-bottom: 14px; }

.sky-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 244, 220, .1);
  color: var(--cream-dim);
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}
.sky-tag--gold { background: rgba(255, 220, 147, .16); color: var(--gold); }
.sky-tag--pink { background: rgba(235, 167, 175, .18); color: var(--pink); }
.sky-tag--cream { background: var(--cream); color: var(--ink); font-weight: 600; }
.sky-tag--dim { background: rgba(255, 255, 255, .05); color: var(--cream-faint); }

.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 20px;
  text-align: center;
}
.state-box__orb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffaf0 0 18%, rgba(255, 236, 196, .6) 34%, transparent 70%);
  animation: orb-pulse 1.6s ease-in-out infinite;
}
@keyframes orb-pulse {
  0%, 100% { transform: scale(.82); opacity: .65; }
  50% { transform: scale(1.12); opacity: 1; }
}
.state-box__title { font-size: 17px; font-weight: 600; letter-spacing: .05em; }
.state-box__msg { max-width: 460px; color: var(--cream-dim); }
.state-box__actions { display: flex; gap: 10px; margin-top: 6px; }

.skeleton {
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(255, 244, 220, .05) 0%, rgba(255, 244, 220, .12) 50%, rgba(255, 244, 220, .05) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(14, 19, 22, .9);
  color: var(--cream);
  box-shadow: inset 0 0 0 1px rgba(255, 244, 220, .2), 0 8px 24px rgba(0, 0, 0, .35);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s, transform .25s;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--error { color: var(--pink); }

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

.fade-in { animation: fade-up .35s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  :root { --topbar-h: 52px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar__brand { gap: 6px; flex: none; }
  .topbar__brand span { font-size: 15px; letter-spacing: .02em; }
  .topbar__brand img { width: 22px; height: 22px; }
  .topbar__nav { flex: none; }
  .topbar__nav a { padding: 4px 12px; font-size: 13px; }
  .app { width: calc(100% - 20px); padding-top: 14px; padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  :root { --r-cell: 16px; --r-panel: 20px; }
}

/* 窄屏（≈360px）：顶栏只保留图标 + 标题，导航项等宽 */
@media (max-width: 400px) {
  :root { --topbar-h: 48px; }
  .topbar { padding: 0 8px; }
  .topbar__brand { min-width: 0; }
  .topbar__brand span {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar__nav { gap: 2px; padding: 3px; }
  .topbar__nav a { padding: 4px 10px; font-size: 12.5px; white-space: nowrap; }
  .app { width: calc(100% - 12px); }
  /* 输入框字号 ≥16px 可避免 iOS 聚焦时自动缩放页面 */
  .sky-input, .home-search__input, .wd-search, .admin-search { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .sky-bg__motes { display: none; }
}
