:root {
  --bg-deep: #05070f;
  --panel: rgba(15, 22, 44, .68);
  --panel-solid: #0d1328;
  --border: rgba(120, 160, 255, .18);
  --border-glow: rgba(63, 224, 255, .55);
  --text: #e8eeff;
  --muted: #93a3c8;
  --accent: #3fe0ff;
  --accent2: #8f7bff;
  --gold: #ffd37a;
  --accent-hover: #7feaff;
}

* { box-sizing: border-box; }

/* 键盘焦点可见性 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 深色主题滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(120, 160, 255, .22);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(120, 160, 255, .42); background-clip: content-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(143, 123, 255, .30), transparent 62%),
    radial-gradient(820px 520px at 92% 8%, rgba(63, 224, 255, .17), transparent 60%),
    radial-gradient(720px 620px at 50% 112%, rgba(255, 211, 122, .13), transparent 56%),
    var(--bg-deep);
  background-attachment: fixed;
}
/* 玄幻网格底纹 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 160, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, .055) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 26%, #000 18%, transparent 78%);
  mask-image: radial-gradient(ellipse at 50% 26%, #000 18%, transparent 78%);
}

/* ---------- 顶部友情合作条 ---------- */
.toplink {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 18px;
  background: linear-gradient(90deg, transparent, rgba(143, 123, 255, .16), transparent);
  border-bottom: 1px solid rgba(120, 160, 255, .12);
  font-size: 12px;
}
.toplink-label { color: var(--muted); letter-spacing: 2px; }
.toplink a {
  color: var(--gold);
  text-decoration: none;
  font-family: "Oxanium", monospace;
  letter-spacing: .6px;
  padding: 2px 11px;
  border: 1px solid rgba(255, 211, 122, .42);
  border-radius: 999px;
  text-shadow: 0 0 9px rgba(255, 211, 122, .5);
  transition: .2s ease;
}
.toplink a:hover {
  background: rgba(255, 211, 122, .12);
  box-shadow: 0 0 14px rgba(255, 211, 122, .35);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(15, 22, 44, .88), rgba(15, 22, 44, .55));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand h1 {
  font-family: "ZCOOL XiaoWei", "PingFang SC", serif;
  font-size: 25px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 3px;
  background: linear-gradient(90deg, #7feaff, #b9a8ff 58%, #ffd37a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(63, 224, 255, .35));
}
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 4px; }

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

button {
  border: 1px solid var(--border);
  background: rgba(20, 30, 60, .6);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  letter-spacing: .5px;
  transition: .18s ease;
}
button:hover:not(:disabled) {
  border-color: var(--border-glow);
  background: rgba(30, 44, 82, .72);
  box-shadow: 0 0 14px rgba(63, 224, 255, .22);
}
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary {
  background: linear-gradient(90deg, #1f6fe0, #3fd0ff);
  border-color: rgba(63, 224, 255, .55);
  color: #04121f;
  font-weight: 600;
  box-shadow: 0 0 16px rgba(63, 224, 255, .35);
}
button.primary:hover:not(:disabled) {
  box-shadow: 0 0 22px rgba(63, 224, 255, .55);
  filter: brightness(1.06);
}

.status { color: var(--muted); font-size: 13px; }

/* ---------- 三栏布局 ---------- */
.layout {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px 320px;
  min-height: 0;
}

.preview-pane {
  padding: 20px;
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--border);
}
.preview-box {
  position: relative;
  background:
    radial-gradient(620px 420px at 50% 38%, rgba(63, 224, 255, .07), transparent 70%),
    rgba(10, 15, 30, .6);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: 300px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  box-shadow: inset 0 0 44px rgba(0, 0, 0, .42);
}
.preview-box .placeholder {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.ph-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  border: 1px solid rgba(63, 224, 255, .3);
  border-radius: 50%;
  color: var(--accent);
  background: radial-gradient(circle at 50% 30%, rgba(63, 224, 255, .12), transparent 70%);
  box-shadow: inset 0 0 24px rgba(63, 224, 255, .18);
}
.ph-icon svg { opacity: .85; }
.ph-title { font-size: 15px; color: var(--text); letter-spacing: 2px; }
.ph-sub { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.preview-box img {
  max-width: 100%;
  max-height: 100%;
  display: none;
  border-radius: 8px;
  box-shadow: 0 10px 44px rgba(0, 0, 0, .55);
}
.compose-progress {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 11px 15px 13px;
  background: rgba(8, 12, 26, .85);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
  pointer-events: none;
  z-index: 5;
}
.compose-progress.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.cp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 1px;
}
.cp-stage { color: var(--text); }
.cp-pct { color: var(--accent); font-family: "Oxanium", monospace; letter-spacing: .4px; }
.cp-bar {
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(63, 224, 255, .15);
}
.cp-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f6fed, #57d2ff, #8f7bff, #2f6fed);
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width .25s ease;
  animation: bar-flow 1.6s linear infinite;
}

.texture-pane { padding: 16px; border-right: 1px solid var(--border); overflow-y: auto; }
.param-pane { padding: 16px; overflow-y: auto; }
.texture-pane h2, .param-pane h2 {
  font-size: 14px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 1px;
}

.tex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tex-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(20, 30, 60, .5);
  transition: .18s ease;
}
.tex-item:hover { border-color: var(--border-glow); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }
.tex-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.tex-item span {
  display: block;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tex-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(63, 224, 255, .42);
}
.tex-item.active::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04121f;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .42);
}
.loading { color: var(--muted); font-size: 13px; }
.tex-hint { color: var(--muted); font-size: 12px; margin: -6px 0 12px; line-height: 1.5; }

.param-group { display: flex; flex-direction: column; }
.param-collapse {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.param-collapse summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 1px;
  user-select: none;
  padding: 2px;
  transition: .18s ease;
}
.param-collapse summary::-webkit-details-marker { display: none; }
.param-collapse summary::marker { content: ""; }
.param-collapse summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--accent);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .18s ease;
}
.param-collapse[open] summary::before { transform: rotate(90deg); }
.param-collapse summary:hover { color: var(--text); }
.param-row { margin-bottom: 15px; }
.param-row .label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.param-row .value { color: var(--accent); font-family: "Oxanium", monospace; letter-spacing: .4px; }
.param-row input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  --pct: 0%;
}
.param-row input[type=range]:focus-visible { outline: none; }
/* WebKit 轨道与滑块 */
.param-row input[type=range]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent), var(--accent2)) 0 0 / var(--pct) 100% no-repeat,
    rgba(120, 160, 255, .16);
}
.param-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: #eaf6ff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(63, 224, 255, .7);
  transition: transform .15s ease, box-shadow .15s ease;
}
.param-row input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.15); }
.param-row input[type=range]:active::-webkit-slider-thumb { transform: scale(1.3); }
.param-row input[type=range]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(63, 224, 255, .28), 0 0 14px rgba(63, 224, 255, .85);
}
/* Firefox 轨道与滑块 */
.param-row input[type=range]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(120, 160, 255, .16);
}
.param-row input[type=range]::-moz-range-progress {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.param-row input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #eaf6ff;
  box-shadow: 0 0 10px rgba(63, 224, 255, .7);
}
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 8px; }

/* ---------- 使用说明模态框 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(4, 7, 16, .68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  background: linear-gradient(180deg, rgba(22, 32, 62, .98), rgba(13, 19, 40, .98));
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 560px;
  max-width: 100%;
  max-height: 82vh;
  overflow: auto;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6), 0 0 30px rgba(63, 224, 255, .12);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; letter-spacing: 1px; }
.modal-close {
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 8px 20px 20px; }
.help-steps { margin: 8px 0 4px; padding-left: 20px; line-height: 1.9; font-size: 14px; }
.help-steps li { margin-bottom: 8px; }
.help-steps b { color: var(--accent); }
.help-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  background: rgba(63, 224, 255, .06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 14px 0 0;
}

/* ---------- 科技风加载层 ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% 40%, rgba(20, 42, 84, .7), rgba(3, 7, 16, .97)),
    #040810;
  color: #d7e3ff;
  overflow: hidden;
  transition: opacity .5s ease, visibility .5s ease;
}
.loader.done { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(63, 224, 255, .09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63, 224, 255, .09) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 76%);
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 76%);
  animation: grid-move 6s linear infinite;
}
@keyframes grid-move {
  to { background-position: 44px 44px, 44px 44px; }
}

.loader-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(180deg, transparent, rgba(80, 200, 255, .16), transparent);
  animation: scan 3.2s ease-in-out infinite;
}
@keyframes scan {
  0% { top: -40%; }
  60%, 100% { top: 100%; }
}

.loader-core { position: relative; z-index: 2; text-align: center; }

.loader-ring { position: relative; width: 168px; height: 168px; margin: 0 auto 26px; }
.loader-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(63, 224, 255, .14); stroke-width: 6; }
.ring-fg {
  fill: none;
  stroke: #3fe0ff;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .6s ease;
  filter: drop-shadow(0 0 8px rgba(63, 224, 255, .8));
}
.loader-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loader-pct span {
  font-family: "Oxanium", monospace;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(63, 224, 255, .75);
}
.loader-pct em { font-style: normal; font-size: 16px; margin-left: 2px; opacity: .7; }

.loader-brand {
  font-family: "ZCOOL XiaoWei", "PingFang SC", serif;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 7px;
  text-shadow: 0 0 16px rgba(63, 224, 255, .7);
}
.loader-stage { margin-top: 10px; font-size: 13px; color: #8fb4e8; letter-spacing: 1px; }
.loader-bar {
  width: 320px;
  max-width: 72vw;
  height: 5px;
  margin: 24px auto 14px;
  background: rgba(63, 224, 255, .15);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.loader-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f6fed, #57d2ff, #8f7bff, #2f6fed);
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width .6s ease;
  animation: bar-flow 1.6s linear infinite;
}
@keyframes bar-flow {
  to { background-position: -200% 0; }
}
.loader-tip { font-size: 11px; color: #5f7ea8; letter-spacing: .5px; }

.loader-corner { position: absolute; width: 26px; height: 26px; border: 2px solid rgba(63, 224, 255, .7); }
.loader-corner.tl { top: 22px; left: 22px; border-right: 0; border-bottom: 0; }
.loader-corner.tr { top: 22px; right: 22px; border-left: 0; border-bottom: 0; }
.loader-corner.bl { bottom: 22px; left: 22px; border-right: 0; border-top: 0; }
.loader-corner.br { bottom: 22px; right: 22px; border-left: 0; border-top: 0; }

/* ---------- 手机端适配 ---------- */
@media (max-width: 768px) {
  body { height: auto; min-height: 100vh; }

  .toplink { justify-content: center; }

  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .brand { width: 100%; }
  .brand h1 { font-size: 20px; }
  .brand-sub { letter-spacing: 2px; }
  .topbar .status { font-size: 12px; }
  .actions { width: 100%; flex-wrap: wrap; gap: 8px; margin-left: 0; }
  .actions .status { width: 100%; font-size: 12px; }

  .layout { display: flex; flex-direction: column; }
  .preview-pane {
    height: 42vh;
    min-height: 240px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }
  .texture-pane { border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; padding: 14px; }
  .param-pane { overflow: visible; padding: 14px; }
  .tex-grid { grid-template-columns: repeat(3, 1fr); }
  .param-row input[type=range] { height: 34px; }
}

/* ---------- 减弱动效（无障碍） ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}