:root {
  --bg: #f8f9fd;
  --bg-soft: #f0f2fa;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --primary: #7c3aed;
  --primary-2: #4f46e5;
  --primary-hover: #6d28d9;
  --accent: #ec4899;
  --border: rgba(209, 213, 219, 0.6);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow: 0 8px 32px rgba(31, 41, 55, 0.08);
  --shadow-lg: 0 18px 50px rgba(31, 41, 55, 0.14);
  --shadow-primary: 0 10px 30px rgba(124, 58, 237, 0.28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* 装饰光斑 */
.bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: floatOrb 18s ease-in-out infinite;
}

.orb-1 {
  width: 420px;
  height: 420px;
  background: linear-gradient(135deg, #c4b5fd, #818cf8);
  top: -120px;
  left: -120px;
  animation-delay: 0s;
}

.orb-2 {
  width: 360px;
  height: 360px;
  background: linear-gradient(135deg, #f9a8d4, #f472b6);
  top: 20%;
  right: -100px;
  animation-delay: -5s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, #93c5fd, #60a5fa);
  bottom: 10%;
  left: -80px;
  animation-delay: -10s;
}

.orb-4 {
  width: 260px;
  height: 260px;
  background: linear-gradient(135deg, #d8b4fe, #a78bfa);
  bottom: -60px;
  right: 10%;
  animation-delay: -14s;
}

@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 25px) scale(0.97); }
}

/* Header */
.header {
  position: relative;
  z-index: 1;
  padding: 42px 32px 64px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 55%, #2563eb 100%);
  overflow: hidden;
}

.header::before,
.header::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}

.header::before {
  width: 360px;
  height: 360px;
  background: rgba(255, 255, 255, 0.18);
  top: -140px;
  left: 50%;
  transform: translateX(-50%);
}

.header::after {
  width: 200px;
  height: 200px;
  background: rgba(236, 72, 153, 0.22);
  bottom: -60px;
  right: 15%;
}

.header-inner {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 32px;
  padding: 14px 26px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.brand-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffffff, #e0e7ff);
  color: #7c3aed;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.brand-icon svg {
  width: 34px;
  height: 34px;
}

.brand-text {
  text-align: left;
}

.brand-text h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.brand-text p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.88;
  font-weight: 400;
}

.header-wave {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 1;
}

.header-wave svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Main */
.main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  gap: 28px;
  padding: 0 32px 32px;
  max-width: 1400px;
  margin: -36px auto 0;
  width: 100%;
  align-items: flex-start;
}

/* 面板 */
.panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  padding: 26px;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  color: var(--primary);
  border-radius: 12px;
}

.panel-icon svg {
  width: 22px;
  height: 22px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.group {
  border-top: 1px dashed var(--border);
  padding-top: 18px;
  margin-top: 18px;
}

.group:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.group h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

/* 上传卡片 */
.file-label {
  display: block;
  cursor: pointer;
}

.upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.04), rgba(124, 58, 237, 0.01));
  transition: all 0.25s ease;
}

.upload-card:hover {
  border-color: #c4b5fd;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.08), rgba(124, 58, 237, 0.02));
  transform: translateY(-2px);
}

.upload-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ede9fe, #dbeafe);
  color: var(--primary);
  border-radius: 14px;
}

.upload-icon svg {
  width: 26px;
  height: 26px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-name {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
  text-align: center;
  line-height: 1.5;
  min-height: 18px;
}

.file-name.has-file {
  color: var(--primary);
  font-weight: 500;
}

/* 卡密激活 */
.group-card {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.05), rgba(124, 58, 237, 0.01));
  border: 1px dashed rgba(124, 58, 237, 0.25);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 0;
}

.card-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.card-input-wrap {
  display: flex;
  gap: 8px;
}

.card-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--panel-solid);
  color: var(--text);
  outline: none;
  transition: all 0.2s ease;
}

.card-input:focus {
  border-color: #c4b5fd;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.card-input::placeholder {
  color: #9ca3af;
}

.btn-activate {
  padding: 10px 14px;
  white-space: nowrap;
}

.btn-activate .btn-icon svg {
  width: 16px;
  height: 16px;
}

.card-status {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  min-height: 18px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: none;
}

.card-status.show {
  display: block;
}

.card-status.success {
  background: rgba(34, 197, 94, 0.08);
  color: #15803d;
}

.card-status.error {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
}

.card-status.warning {
  background: rgba(245, 158, 11, 0.08);
  color: #b45309;
}

/* 字段 */
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.field input[type="number"] {
  width: 90px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  text-align: center;
  background: var(--panel-solid);
  color: var(--text);
  outline: none;
  transition: all 0.2s ease;
}

.field input[type="number"]:focus {
  border-color: #c4b5fd;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.field select {
  min-width: 130px;
  max-width: 170px;
  padding: 8px 28px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  text-align: center;
  text-align-last: center;
  background: var(--panel-solid);
  color: var(--text);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.2s ease;
}

.field select:focus {
  border-color: #c4b5fd;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.field-check {
  justify-content: space-between;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

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

.switch-track {
  position: absolute;
  inset: 0;
  background: #e5e7eb;
  border-radius: 24px;
  transition: background 0.25s ease;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked + .switch-track {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:focus + .switch-track {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 4px rgba(124, 58, 237, 0.12);
}

/* 按钮 */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transition: left 0.5s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn:hover:not(:disabled)::before {
  left: 100%;
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #4338ca 100%);
  box-shadow: 0 14px 36px rgba(124, 58, 237, 0.35);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.btn-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
}

/* Workspace */
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.preview-area {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  padding: 28px;
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(20px);
}

.preview-area::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(37, 99, 235, 0.08), rgba(236, 72, 153, 0.12));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.placeholder {
  text-align: center;
  color: var(--text-secondary);
}

.placeholder-art {
  width: 160px;
  height: 160px;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(59, 130, 246, 0.06));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.placeholder-art svg {
  width: 120px;
  height: 120px;
}

.placeholder p {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.placeholder-tip {
  display: inline-block;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(124, 58, 237, 0.06);
  padding: 5px 12px;
  border-radius: 20px;
}

.hidden {
  display: none !important;
}

#previewCanvas {
  max-width: 100%;
  max-height: 75vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Legend */
.legend {
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  padding: 22px 26px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(20px);
}

.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}

.legend h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.legend-summary {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(124, 58, 237, 0.06);
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 13px;
  background: var(--panel-solid);
  transition: all 0.2s ease;
  cursor: default;
}

.legend-item:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-sm);
  border-color: #c4b5fd;
}

.legend-color {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.legend-name {
  font-weight: 500;
  color: var(--text);
}

.legend-count {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Footer */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 22px 16px 28px;
  color: var(--text-secondary);
  font-size: 13px;
}

.footer p {
  margin: 0;
}

/* 响应式 */
@media (max-width: 980px) {
  .main {
    flex-direction: column;
    align-items: stretch;
    margin-top: -28px;
    padding: 0 20px 24px;
  }

  .panel {
    width: 100%;
  }

  .header {
    padding: 32px 20px 56px;
  }

  .brand {
    flex-direction: column;
    text-align: center;
    padding: 18px 22px;
  }

  .brand-text {
    text-align: center;
  }

  .brand-text h1 {
    font-size: 22px;
  }

  .preview-area {
    min-height: 360px;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .brand-icon {
    width: 48px;
    height: 48px;
  }

  .brand-icon svg {
    width: 28px;
    height: 28px;
  }

  .brand-text h1 {
    font-size: 20px;
  }

  .panel {
    padding: 20px;
    border-radius: var(--radius-lg);
  }

  .preview-area {
    border-radius: var(--radius-lg);
    min-height: 300px;
  }

  .field select {
    max-width: 140px;
  }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  .orb,
  .btn::before,
  .upload-card,
  .legend-item,
  .btn,
  .switch-track::after {
    animation: none;
    transition: none;
  }
}
