/* ==========================================================================
 * style.css —— 页面骨架与侧边控制面板
 * ========================================================================== */

:root {
  --bg-deep: #04060f;
  --text: #dfe8ff;
  --muted: #8ea2c2;
  --dim: #5f7391;
  --accent: #7fd4ff;
  --accent-soft: rgba(127, 212, 255, 0.18);
  --gold: #ffd166;
  --danger: #ff7b8f;
  --panel-width: 344px;
  --line: rgba(127, 212, 255, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: #04060f;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 50% 45%, #0b1428 0%, #04060f 55%, #01020a 100%);
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 48%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 1;
}

/* ------------------------------ 加载与错误 ------------------------------ */

.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg-deep);
  transition: opacity 0.6s ease;
}

.loading.hide {
  opacity: 0;
  pointer-events: none;
}

.loading-ring {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid rgba(127, 212, 255, 0.16);
  border-top-color: var(--accent);
  box-shadow: 0 0 32px rgba(127, 212, 255, 0.35);
  animation: spin 1s linear infinite;
}

.loading p {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #b9d4f2;
}

.loading small {
  color: #566a88;
  font-size: 11px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fatal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(3, 5, 12, 0.97);
  color: var(--text);
}

.fatal h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--gold);
}

.fatal p {
  margin: 0;
  font-size: 13px;
  line-height: 1.9;
  color: var(--muted);
}

.fatal pre {
  margin: 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
  color: #7f9fc4;
  overflow-x: auto;
}

/* ------------------------------ 面板骨架 ------------------------------ */

.panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: var(--panel-width);
  background: linear-gradient(180deg, rgba(8, 13, 25, 0.93), rgba(5, 8, 18, 0.88));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform 0.38s cubic-bezier(0.3, 0.8, 0.3, 1);
}

.panel.collapsed {
  transform: translateX(-103%);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-dot {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8f9ff, #7fd4ff 45%, #3a6bff 100%);
  box-shadow: 0 0 16px rgba(127, 212, 255, 0.75);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  min-width: 0;
}

.brand-text strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #eaf5ff;
}

.brand-text small {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.icon-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.2s;
}

.icon-btn:hover {
  border-color: rgba(127, 212, 255, 0.4);
  color: var(--accent);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(127, 212, 255, 0.22) transparent;
}

.panel-body::-webkit-scrollbar {
  width: 8px;
}

.panel-body::-webkit-scrollbar-thumb {
  background: rgba(127, 212, 255, 0.2);
  border-radius: 4px;
}

.block {
  padding: 16px 0;
  border-bottom: 1px dashed rgba(127, 212, 255, 0.08);
}

.block:last-of-type {
  border-bottom: none;
}

.block h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9db6d8;
}

.block h2 small {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--dim);
}

/* ------------------------------ 预设按钮 ------------------------------ */

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid rgba(127, 212, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: 0.18s;
}

.preset-btn:hover {
  border-color: rgba(127, 212, 255, 0.35);
  background: rgba(127, 212, 255, 0.06);
}

.preset-btn.active {
  border-color: rgba(127, 212, 255, 0.7);
  background: linear-gradient(135deg, rgba(127, 212, 255, 0.16), rgba(124, 157, 255, 0.08));
  box-shadow: inset 0 0 18px rgba(127, 212, 255, 0.14);
}

.preset-name {
  font-size: 12.5px;
}

.preset-hint {
  font-size: 10px;
  color: var(--dim);
}

.preset-btn.active .preset-hint {
  color: #a9c8e8;
}

/* 分段切换：聚合 / 散开 */
.segmented {
  display: flex;
  gap: 4px;
  margin: 12px 0 8px;
  padding: 4px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(127, 212, 255, 0.08);
}

.segmented button {
  flex: 1;
  padding: 7px 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: 0.2s;
}

.segmented button.active {
  background: rgba(127, 212, 255, 0.16);
  color: #eaf7ff;
  box-shadow: 0 0 14px rgba(127, 212, 255, 0.14);
}

/* ------------------------------ 通用控件 ------------------------------ */

.ctrl {
  margin: 11px 0;
}

.ctrl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 12px;
  color: #b7c9e2;
}

.ctrl-head output {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #9fdcff;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(127, 212, 255, 0.55), rgba(127, 212, 255, 0.12));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  border-radius: 50%;
  border: none;
  background: #e6f8ff;
  box-shadow: 0 0 10px rgba(127, 212, 255, 0.85);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(127, 212, 255, 0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: #e6f8ff;
  box-shadow: 0 0 10px rgba(127, 212, 255, 0.85);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 12px;
  color: #b7c9e2;
  cursor: pointer;
}

.switch-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.ctrl-color {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: #b7c9e2;
}

.color-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.color-row label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(127, 212, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11.5px;
  color: var(--muted);
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 6px;
}

.field {
  display: block;
  margin: 9px 0;
}

.field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

.field input[type="text"],
.field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(127, 212, 255, 0.14);
  background: rgba(3, 7, 16, 0.65);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: 0.2s;
}

.field input[type="text"]::placeholder {
  color: #4f6484;
}

.field input[type="text"]:focus,
.field select:focus {
  border-color: rgba(127, 212, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(127, 212, 255, 0.1);
}

.field select option {
  background: #0a1120;
  color: var(--text);
}

/* ------------------------------ 按钮 ------------------------------ */

.solid-btn,
.ghost-btn,
.danger-btn {
  padding: 9px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: 0.2s;
}

.solid-btn {
  flex: 1;
  border: 1px solid rgba(127, 212, 255, 0.5);
  background: linear-gradient(135deg, rgba(127, 212, 255, 0.26), rgba(90, 120, 255, 0.18));
  color: #eaf7ff;
}

.solid-btn:hover {
  border-color: rgba(127, 212, 255, 0.85);
  box-shadow: 0 0 18px rgba(127, 212, 255, 0.22);
}

.ghost-btn {
  flex: 1;
  width: 100%;
  border: 1px solid rgba(127, 212, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: #b7c9e2;
}

.ghost-btn:hover {
  border-color: rgba(127, 212, 255, 0.45);
  color: #eaf7ff;
}

#btn-reset-shape {
  margin-top: 2px;
}

.danger-btn {
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(255, 123, 143, 0.28);
  background: rgba(255, 123, 143, 0.06);
  color: #ffb3c0;
}

.danger-btn:hover {
  border-color: rgba(255, 123, 143, 0.6);
  background: rgba(255, 123, 143, 0.12);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.file-btn {
  position: relative;
  display: block;
  padding: 9px 10px;
  border: 1px dashed rgba(127, 212, 255, 0.3);
  border-radius: 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
  transition: 0.2s;
}

.file-btn:hover {
  background: rgba(127, 212, 255, 0.07);
  border-color: rgba(127, 212, 255, 0.55);
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.hint {
  margin: 9px 0 0;
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--dim);
}

.hint.error {
  color: #ff9aab;
}

.panel-foot {
  padding: 16px 0 8px;
  border-top: 1px solid rgba(127, 212, 255, 0.08);
  font-size: 10.5px;
  line-height: 1.75;
  text-align: center;
  color: #566a88;
}

/* 自定义音乐播放器 */
.player {
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(127, 212, 255, 0.14);
  background: linear-gradient(160deg, rgba(127, 212, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.player + .player {
  margin-top: 10px;
}

.player-tag {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: #7fd4ff;
  opacity: 0.8;
  margin-bottom: 2px;
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.player-title {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #eaf5ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-sub {
  font-size: 10px;
  color: #6b80a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(127, 212, 255, 0.5);
  background: radial-gradient(circle at 35% 30%, rgba(127, 212, 255, 0.35), rgba(80, 120, 255, 0.12));
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.play-btn:hover {
  border-color: rgba(127, 212, 255, 0.85);
  box-shadow: 0 0 18px rgba(127, 212, 255, 0.35);
}

.play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #dff4ff;
  margin-left: 3px;
}

.play-btn.is-playing .play-icon {
  width: 12px;
  height: 14px;
  border: 0;
  margin-left: 0;
  background: linear-gradient(
    90deg,
    #dff4ff 0 36%,
    transparent 36% 64%,
    #dff4ff 64% 100%
  );
  box-sizing: border-box;
}

.player-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font-size: 10px;
  color: #6b80a0;
  font-variant-numeric: tabular-nums;
}

.player-progress input[type='range'] {
  flex: 1;
  min-width: 0;
}

.source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(127, 212, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: #8ea2c2;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.chip:hover {
  border-color: rgba(127, 212, 255, 0.4);
  color: #cfe6ff;
}

.chip.active {
  border-color: rgba(127, 212, 255, 0.65);
  background: rgba(127, 212, 255, 0.14);
  color: #eaf7ff;
}

.chip-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
}

.chip-upload input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#music-controls {
  margin-top: 10px;
}

.panel-foot p {
  margin: 0;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 6px;
}

.foot-links a {
  color: #8ea2c2;
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
}

.foot-links a:hover {
  color: #7fd4ff;
  text-shadow: 0 0 8px rgba(127, 212, 255, 0.5);
}

.foot-links span {
  color: #3d4f6a;
}

.foot-copy {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #4a5c78;
}

/* ------------------------------ 浮动元素 ------------------------------ */

.panel-open {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 21;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(127, 212, 255, 0.35);
  background: rgba(8, 14, 26, 0.82);
  color: #dff4ff;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.downgrade {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.5);
  background: rgba(38, 28, 10, 0.88);
  color: #ffe9b0;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: 0 0 26px rgba(255, 209, 102, 0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.downgrade:hover {
  border-color: rgba(255, 209, 102, 0.9);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 40;
  max-width: min(88vw, 420px);
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(127, 212, 255, 0.3);
  background: rgba(10, 18, 32, 0.92);
  color: #dff4ff;
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

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

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 860px) {
  :root {
    --panel-width: min(86vw, 344px);
  }

  .panel {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }

  .panel-head {
    padding: 14px 16px 12px;
  }

  .panel-body {
    padding: 4px 16px 20px;
  }

  .toast {
    bottom: 24px;
  }
}

@media (max-height: 620px) {
  .block {
    padding: 12px 0;
  }
}
