/* ===== 全局基础样式 ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Microsoft YaHei', '微软雅黑', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== 面板卡片 ===== */
.panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===== 表单元素 ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.form-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='rgba(255,255,255,0.4)' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-select:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.form-select option {
  background: #1e1b4b;
  color: white;
}

/* ===== 滑块 ===== */
.range-slider {
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background 0.2s;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.7);
}

.range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.5);
}

/* ===== 样式按钮 ===== */
.style-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.style-btn:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: rgba(124, 58, 237, 0.4);
  color: white;
}

.style-btn.active {
  background: rgba(124, 58, 237, 0.3);
  border-color: #7c3aed;
  color: #a78bfa;
}

/* ===== 颜色选择器 ===== */
.color-picker-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.color-picker-wrap:hover {
  border-color: rgba(124, 58, 237, 0.6);
}

.color-input {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.color-preview {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  z-index: 1;
}

/* ===== 预设颜色 ===== */
.preset-color {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.preset-color:hover {
  transform: scale(1.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* ===== 开关 ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  transition: background 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-track::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: rgba(124, 58, 237, 0.5);
  border-color: #7c3aed;
}

.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(16px);
  background: #a78bfa;
}

/* ===== 预览容器 ===== */
.preview-container {
  padding: 24px;
  transition: background 0.3s;
}

.preview-container.bg-white {
  background: #ffffff !important;
}

.preview-container.bg-black {
  background: #000000 !important;
}

.preview-container.bg-gray {
  background: #6b7280 !important;
}

/* ===== 棋盘格背景（透明效果） ===== */
.checkerboard-bg {
  background-image:
    linear-gradient(45deg, #374151 25%, transparent 25%),
    linear-gradient(-45deg, #374151 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #374151 75%),
    linear-gradient(-45deg, transparent 75%, #374151 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #1f2937;
}

.checkerboard {
  background-image:
    linear-gradient(45deg, #9ca3af 25%, transparent 25%),
    linear-gradient(-45deg, #9ca3af 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #9ca3af 75%),
    linear-gradient(-45deg, transparent 75%, #9ca3af 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  background-color: #d1d5db;
}

/* ===== 预览背景按钮 ===== */
.bg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.bg-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.bg-btn.active {
  background: rgba(124, 58, 237, 0.2);
  border-color: rgba(124, 58, 237, 0.5);
  color: #a78bfa;
}

/* ===== 导出按钮 ===== */
.export-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6);
}

.export-btn:active {
  transform: translateY(0);
}

.copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: white;
}

/* ===== 预设卡片 ===== */
.preset-card {
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.2s;
  overflow: hidden;
  position: relative;
}

.preset-card:hover {
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.preset-card canvas {
  width: 100%;
  height: 60px;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.preset-card .preset-name {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  margin-top: 8px;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.5);
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel {
  animation: fadeIn 0.3s ease-out;
}

/* ===== 折叠面板 ===== */
.collapsible .panel-title {
  margin-bottom: 0;
  border-bottom: none;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.collapsible .panel-title:hover {
  color: rgba(255, 255, 255, 1);
}

.collapsible .panel-title:hover .collapse-icon {
  color: rgba(167, 139, 250, 0.8);
}

.collapsible-body {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.3s ease;
  opacity: 1;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.collapsible.collapsed .collapsible-body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.collapsible.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.collapse-icon {
  transition: transform 0.3s ease, color 0.2s;
}