:root {
  --accent: #ff3b6b;
  --glass-bg: rgba(16, 18, 27, 0.62);
  --glass-border: rgba(255, 255, 255, 0.14);
  --text: #eef1f7;
  --muted: #9aa3b2;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: #07080d;
  color: var(--text);
  opacity: 0;
  transition: opacity 1.2s ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
body.ready { opacity: 1; }

/* 无限滚动代码背景 */
#code-bg {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  opacity: 0.5;
}

/* 3D 场景 */
#scene-container { position: fixed; inset: 0; z-index: 1; }
#scene-container canvas { display: block; touch-action: none; }

/* 顶部标题 */
#hero {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 3;
  text-align: center; pointer-events: none;
}
#hero h1 {
  font-size: 26px; font-weight: 700; letter-spacing: 2px;
  background: linear-gradient(90deg, #ff3b6b, #ff9db8, #ffd1dd, #ff3b6b);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 5s linear infinite;
  filter: drop-shadow(0 0 14px rgba(255, 59, 107, 0.45));
}
@keyframes shine { to { background-position: 220% 0; } }
#hero p { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ---------- 控制面板 ---------- */
#panel {
  position: fixed; left: 18px; top: 50%; transform: translateY(-50%);
  z-index: 4; width: 282px;
  padding: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}
#panel.collapsed {
  transform: translateX(calc(-100% - 46px)) translateY(-50%);
  opacity: 0; pointer-events: none;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px 10px;
}
.panel-title { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.panel-body { padding: 0 16px 16px; }
.only-mobile { display: none; }
#panel-close {
  border: none; background: rgba(255,255,255,0.08); color: var(--text);
  width: 30px; height: 30px; border-radius: 50%; font-size: 14px; cursor: pointer;
}
#panel-close:active { background: rgba(255,255,255,0.2); }

/* 折叠/展开按钮 */
#panel-toggle {
  position: fixed; top: calc(16px + env(safe-area-inset-top)); left: 16px;
  z-index: 5; width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text); font-size: 20px; cursor: pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  transition: transform 0.2s ease, background 0.2s ease;
}
#panel-toggle:active { transform: scale(0.92); }
#panel-toggle.open { background: rgba(255,59,107,0.28); border-color: var(--accent); }

/* 移动端点击遮罩(仅移动端显示, 见媒体查询里的 .show) */
#panel-backdrop {
  display: none; position: fixed; inset: 0; z-index: 2;
  background: rgba(5, 6, 10, 0.4);
}

.ctrl { margin-bottom: 16px; }
.ctrl > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }

/* 色板 */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: #fff; box-shadow: 0 0 12px rgba(255,255,255,0.6); }

/* 花束种类 */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button {
  padding: 10px 6px; font-size: 13px; color: var(--text);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border); border-radius: 10px; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.seg button:hover { background: rgba(255,59,107,0.15); }
.seg button.active {
  background: linear-gradient(135deg, #ff3b6b, #ff7a9e);
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 6px 18px rgba(255,59,107,0.4);
}

/* 发光强度滑杆 */
#glow-range {
  width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,0.14); border-radius: 6px; outline: none;
  accent-color: var(--accent);
}
#glow-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, #ff3b6b, #ff7a9e);
  box-shadow: 0 0 10px rgba(255,59,107,0.7); cursor: pointer; border: 2px solid #fff;
}
.glow-val { color: var(--accent); font-weight: 700; }

/* 光晕颜色 */
.glow-colors { display: flex; gap: 9px; flex-wrap: wrap; }
.glow-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 5px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, border-color 0.2s ease;
  font-size: 12px; line-height: 24px; text-align: center; color: #fff;
  background: rgba(255,255,255,0.08);
}
.glow-swatch:hover { transform: scale(1.12); }
.glow-swatch.active { border-color: #fff; box-shadow: 0 0 12px rgba(255,255,255,0.6); }
.glow-swatch[data-color="auto"] {
  background: conic-gradient(#ff3b6b, #4a7dff, #ffc93c, #ffffff, #ff3b6b);
  color: #000;
}

/* 文字输入 */
.text-row { display: flex; gap: 8px; margin-bottom: 8px; }
#text-input {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 14px; color: var(--text);
  background: rgba(0,0,0,0.32);
  border: 1px solid var(--glass-border); border-radius: 10px;
  outline: none; -webkit-user-select: text; user-select: text;
}
#text-input:focus { border-color: var(--accent); }
button.mini {
  padding: 10px 14px; font-size: 13px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.06); color: var(--text);
}
button.mini.primary {
  background: linear-gradient(135deg, #ff3b6b, #ff7a9e);
  border: none; color: #fff; font-weight: 600;
  box-shadow: 0 6px 18px rgba(255,59,107,0.35);
}

.hint { margin-top: 2px; font-size: 11px; color: var(--muted); text-align: center; }

/* ---------- 移动端: 底部抽屉式面板 ---------- */
@media (max-width: 640px) {
  #hero h1 { font-size: 20px; letter-spacing: 1px; }
  #hero p { font-size: 12px; }

  #panel {
    left: 8px; right: 8px; top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    transform: none;
    width: auto; max-width: none;
    max-height: min(58vh, 520px);
    border-radius: 18px;
  }
  #panel:not(.collapsed) .panel-body { overflow-y: auto; max-height: calc(58vh - 56px); }
  #panel.collapsed {
    transform: translateY(calc(100% + 24px));
    opacity: 0; pointer-events: none;
  }

  .only-mobile { display: inline-flex; }
  .panel-head { padding: 13px 14px 8px; }

  #panel-toggle {
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: 52px; height: 52px; font-size: 22px;
  }
  #panel:not(.collapsed) ~ #panel-toggle { display: none; }
  #panel-backdrop.show { display: block; }

  .swatch { width: 36px; height: 36px; }
  .glow-swatch { width: 34px; height: 34px; line-height: 30px; }
  #glow-range { height: 8px; }
  #glow-range::-webkit-slider-thumb { width: 24px; height: 24px; }
  .seg button { min-height: 42px; font-size: 14px; }
  button.mini { min-height: 42px; }
  #text-input { font-size: 16px; } /* 避免 iOS 聚焦自动放大 */
  .ctrl { margin-bottom: 14px; }
}

.noscript {
  position: fixed; inset: 0; z-index: 99; display: flex; align-items: center;
  justify-content: center; background: #07080d; color: #fff; font-size: 16px;
}
