/* 多彩渐变壁纸 —— 色彩实验室 */

:root {
  --bg-surface: rgba(255, 255, 255, 0.68);
  --bg-hair: rgba(0, 0, 0, 0.10);
  --bg-faint: rgba(0, 0, 0, 0.04);
  --bg-muted: #6b6b76;
  --bg-ink: #1b1b22;
  --bg-mat: #0c0c11;
  --bg-accent: #7b5cff;
  --bg-accent-ink: #ffffff;
  --bg-shadow: 0 26px 60px -32px rgba(20, 16, 40, 0.55);
}

[data-theme="dark"] {
  --bg-surface: rgba(20, 20, 26, 0.62);
  --bg-hair: rgba(255, 255, 255, 0.12);
  --bg-faint: rgba(255, 255, 255, 0.05);
  --bg-muted: #9698a6;
  --bg-ink: #ececf2;
  --bg-mat: #08080b;
  --bg-accent: #8b7cff;
  --bg-shadow: 0 26px 60px -34px rgba(0, 0, 0, 0.8);
}

.bg-tool {
  display: grid;
  grid-template-columns: minmax(0, 430px) minmax(0, 380px);
  grid-template-areas:
    "hero hero"
    "stage rail";
  justify-content: center;
  align-items: start;
  column-gap: clamp(28px, 5vw, 56px);
  row-gap: 26px;
  max-width: 980px;
  margin: 0 auto;
}

/* ---------- 页头 ---------- */
.bg-hero {
  grid-area: hero;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--bg-hair);
}

.bg-hero-copy {
  min-width: 0;
}

.bg-hero h1 {
  position: relative;
  margin: 0 0 10px;
  padding-top: 15px;
  font-size: clamp(25px, 3.4vw, 33px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--bg-ink);
}

.bg-hero h1::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 42px;
  height: 3px;
  border-radius: 2px;
  background: var(--bg-accent);
  transition: background 0.3s;
}

.bg-hero p {
  margin: 0;
  max-width: 46ch;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--bg-muted);
}

.bg-hero-colors {
  display: flex;
  gap: 7px;
  flex: 0 0 auto;
  padding-bottom: 5px;
}

.bg-hero-colors span {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid var(--bg-hair);
}

/* ---------- 画布 ---------- */
.bg-stage {
  grid-area: stage;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
}

.bg-frame {
  position: relative;
  width: 100%;
  max-width: 430px;
  aspect-ratio: var(--ratio, 9 / 16);
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-mat);
  border: 1px solid var(--bg-hair);
  box-shadow: var(--bg-shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.bg-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.bg-stage-note {
  font-size: 12.5px;
  color: var(--bg-muted);
  letter-spacing: 0.3px;
  margin: 0;
}

.bg-stage-bar {
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--bg-hair);
  border-radius: 14px;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

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

.bg-bar-label {
  flex: 0 0 30px;
  font-size: 12px;
  color: var(--bg-muted);
}

.bg-bar-row .bg-seg {
  flex: 1;
  min-width: 0;
}

.bg-bar-row .bg-seg button {
  min-width: 0;
}

.bg-actions {
  width: 100%;
  max-width: 430px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bg-act {
  font: inherit;
  font-size: 13.5px;
  width: 100%;
  padding: 11px 8px;
  border-radius: 11px;
  border: 1px solid var(--bg-hair);
  background: var(--bg-faint);
  color: var(--bg-ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
}

.bg-act:hover {
  background: var(--bg-hair);
}

.bg-act:active {
  transform: translateY(1px);
}

.bg-act.primary {
  background: var(--bg-accent);
  color: var(--bg-accent-ink);
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 12px 28px -14px var(--bg-accent);
}

/* ---------- 控制台 ---------- */
.bg-rail {
  grid-area: rail;
  background: var(--bg-surface);
  border: 1px solid var(--bg-hair);
  border-radius: 18px;
  padding: 20px 20px 22px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.bg-group {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--bg-hair);
}

.bg-rail .bg-group:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.bg-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--bg-muted);
  margin: 0 0 12px;
}

.bg-group-title i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--bg-accent);
  box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.16);
  transition: background 0.3s;
}

/* 调色板 */
.bg-palettes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.bg-pal {
  position: relative;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--bg-hair);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: transform 0.16s, box-shadow 0.16s;
}

.bg-pal:hover {
  transform: translateY(-1px);
}

.bg-pal.on {
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--bg-accent);
}

/* 颜色停靠点 */
.bg-stops {
  display: flex;
  flex-direction: column;
}

.bg-stop {
  display: grid;
  grid-template-columns: 36px 1fr 24px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--bg-hair);
}

.bg-stop:last-child {
  border-bottom: 0;
}

.bg-swatch {
  position: relative;
  width: 36px;
  height: 26px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--bg-hair);
}

.bg-swatch input[type="color"] {
  position: absolute;
  inset: -8px;
  width: 200%;
  height: 200%;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

.bg-stop .pos {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.bg-stop .pos input[type="range"] {
  flex: 1;
  min-width: 0;
}

.bg-stop .pos output {
  width: 34px;
  text-align: right;
  font-size: 11.5px;
  color: var(--bg-muted);
  font-variant-numeric: tabular-nums;
}

.bg-stop .del {
  width: 24px;
  height: 24px;
  line-height: 1;
  border: 1px solid var(--bg-hair);
  border-radius: 7px;
  background: transparent;
  color: var(--bg-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 0;
  transition: color 0.16s, border-color 0.16s;
}

.bg-stop .del:hover {
  color: #ff5d6c;
  border-color: #ff5d6c;
}

.bg-hex {
  display: none;
  font-size: 12px;
  letter-spacing: 0.3px;
  color: var(--bg-muted);
  font-variant-numeric: tabular-nums;
}

.no-pos .bg-stop .pos input[type="range"],
.no-pos .bg-stop .pos output {
  display: none;
}

.no-pos .bg-stop .pos .bg-hex {
  display: inline-block;
}

.bg-inline {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.bg-mini {
  font: inherit;
  font-size: 12.5px;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px dashed var(--bg-hair);
  background: transparent;
  color: var(--bg-muted);
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s;
}

.bg-mini:hover {
  color: var(--bg-ink);
  border-color: var(--bg-accent);
}

/* 分段选择 */
.bg-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bg-seg button {
  flex: 1 1 0;
  min-width: 54px;
  padding: 8px 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--bg-muted);
  background: var(--bg-faint);
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
  font-variant-numeric: tabular-nums;
}

.bg-seg button:hover {
  background: var(--bg-hair);
}

.bg-seg button[aria-pressed="true"] {
  color: var(--bg-accent-ink);
  background: var(--bg-accent);
  box-shadow: 0 8px 20px -12px var(--bg-accent);
}

.bg-seg-sm button {
  min-width: 42px;
  font-size: 12px;
}

/* 滑块行 */
.bg-field {
  display: grid;
  grid-template-columns: 50px 1fr 50px;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.bg-field label {
  font-size: 12.5px;
  color: var(--bg-muted);
}

.bg-field output {
  font-size: 12px;
  color: var(--bg-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bg-field input[type="range"],
.bg-stop .pos input[type="range"] {
  width: 100%;
  height: 22px;
  accent-color: var(--bg-accent);
  cursor: pointer;
}

.bg-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--bg-ink);
  cursor: pointer;
}

.bg-switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--bg-accent);
  cursor: pointer;
}

.bg-wide {
  display: block;
  width: 100%;
  margin-top: 14px;
  font: inherit;
  font-size: 13px;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--bg-hair);
  background: var(--bg-faint);
  color: var(--bg-ink);
  cursor: pointer;
  transition: background 0.16s;
}

.bg-wide:hover {
  background: var(--bg-hair);
}

.bg-tips {
  font-size: 12px;
  line-height: 1.7;
  color: var(--bg-muted);
  margin: 14px 0 0;
}

/* 提示条 */
.bg-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 18, 32, 0.9);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 4000;
}

.bg-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 壁纸模式提示 */
.bg-wpHint {
  position: absolute;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 12.5px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
  z-index: 3;
}

.bg-wpHint.show {
  opacity: 1;
}

/* 键盘可达性 */
.bg-frame:focus-visible,
.bg-act:focus-visible,
.bg-seg button:focus-visible,
.bg-mini:focus-visible,
.bg-wide:focus-visible,
.bg-pal:focus-visible {
  outline: 2px solid var(--bg-accent);
  outline-offset: 2px;
}

/* ---------- 壁纸模式：收敛全部配置，只留画面 ---------- */
body.bg-wp {
  overflow: hidden;
}

body.bg-wp .container > header,
body.bg-wp .container > footer,
body.bg-wp .bg-hero,
body.bg-wp .bg-rail,
body.bg-wp .bg-stage-note,
body.bg-wp .bg-stage-bar,
body.bg-wp .bg-actions,
body.bg-wp .bg-tips {
  display: none !important;
}

/* #pageContent 带 transform/will-change，会成为 fixed 的包含块，这里解除 */
body.bg-wp #pageContent {
  transform: none !important;
  will-change: auto !important;
  opacity: 1 !important;
}

body.bg-wp .container {
  padding: 0 !important;
  max-width: none !important;
}

body.bg-wp .bg-tool {
  display: block;
  max-width: none;
  margin: 0;
}

body.bg-wp .bg-stage {
  display: block;
}

body.bg-wp .bg-frame {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  z-index: 3000;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .bg-tool {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "hero"
      "stage"
      "rail";
    row-gap: 20px;
    max-width: 540px;
  }

  .bg-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .bg-hero-colors {
    display: none;
  }

  .bg-frame,
  .bg-stage-bar,
  .bg-actions {
    max-width: 430px;
  }
}

@media (max-width: 460px) {
  .bg-frame,
  .bg-stage-bar,
  .bg-actions {
    max-width: 100%;
  }

  .bg-act {
    font-size: 12.5px;
    padding: 10px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-toast,
  .bg-wpHint,
  .bg-act,
  .bg-seg button {
    transition: none;
  }
}



