:root {
  --accent: #c86fd6;
  --accent-2: #d98ae0;
  --text: #4a3a52;
  --panel: #fff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #f3e3ff 0%, #ffe3f0 55%, #e3f0ff 100%);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}

.app { height: 100%; display: flex; flex-direction: column; }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 6px; }
.brand { font-size: 18px; font-weight: 800; margin: 0; color: var(--accent); flex: 1; text-shadow: 0 2px 0 #fff; }
.icon-btn { flex: none; width: 38px; height: 38px; border-radius: 50%; border: none; background: #fff; color: var(--accent);
  font-size: 18px; font-weight: 800; box-shadow: var(--shadow); cursor: pointer; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.icon-btn:active { transform: scale(0.92); }
.flower-chip { background: #fff; color: #ff5d8f; font-weight: 800; border-radius: 999px; padding: 7px 12px; font-size: 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 4px; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #7a6a82; background: #fff; padding: 6px 10px; border-radius: 999px; box-shadow: var(--shadow); cursor: pointer; }
.toggle .sw { width: 34px; height: 20px; border-radius: 999px; background: #d8cfe0; position: relative; transition: background .2s; }
.toggle .sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.on .sw { background: var(--accent); }
.toggle.on .sw::after { left: 16px; }

/* 预览 */
.preview { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 6px; }
.preview svg { height: 100%; max-height: 100%; width: auto; max-width: 100%; filter: drop-shadow(0 6px 12px rgba(0,0,0,.12)); }
.preview.adjusting { cursor: grab; touch-action: none; }
.preview.adjusting:active { cursor: grabbing; }
.preview.adjusting svg [data-slot].adjust-target { filter: drop-shadow(0 0 5px rgba(200,111,214,.85)); }

/* 风格选择 */
.styles { display: flex; gap: 8px; padding: 4px 12px; overflow-x: auto; }
.style-chip { flex: none; border: 2px solid #e6d6f0; background: #fff; color: var(--text); font-weight: 800; font-size: 13px; padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.style-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 面板：分类标签 + 款式网格 */
.panel { background: rgba(255,255,255,.72); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-radius: 20px 20px 0 0; box-shadow: 0 -6px 20px rgba(0,0,0,.08); padding: 8px 0 calc(env(safe-area-inset-bottom) + 8px); }
.cats { display: flex; gap: 6px; padding: 4px 12px 8px; overflow-x: auto; }
.cat { flex: none; border: none; background: #f2e8f8; color: #6a5a72; font-weight: 700; font-size: 13px; padding: 8px 12px; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 52px; }
.cat .ic { font-size: 18px; }
.cat.active { background: var(--accent); color: #fff; }
.cat.adjust-target { box-shadow: 0 0 0 3px rgba(200,111,214,.26); }

.items { display: flex; gap: 10px; padding: 4px 12px 8px; overflow-x: auto; min-height: 84px; }
.swatch { flex: none; width: 72px; height: 72px; border-radius: 16px; background: #fff; border: 3px solid #ece0f4; cursor: pointer; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.swatch.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,111,214,.3); }
.swatch svg { width: 100%; height: 100%; }
.swatch img { width: 100%; height: 100%; object-fit: contain; display: block; }
.swatch .color { width: 100%; height: 100%; }
.swatch .none { color: #c0b0cc; font-size: 12px; font-weight: 700; }
.swatch .lock { position: absolute; right: 3px; top: 3px; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 999px; }
.swatch.locked svg, .swatch.locked .color { opacity: .55; filter: grayscale(.4); }
.theme-swatch { width: 92px; height: 72px; background: #f7eefc; }
.theme-swatch .theme-name { position: absolute; left: 4px; right: 4px; bottom: 3px; padding: 2px 4px; border-radius: 8px; background: rgba(255,255,255,.86); color: #5a4664; font-size: 10px; font-weight: 800; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.actions { display: flex; gap: 6px; padding: 6px 12px 2px; }
.act { flex: 1; min-width: 0; height: 58px; border: none; border-radius: 14px; padding: 8px 4px; font-weight: 800; font-size: 13px; line-height: 1.05; white-space: nowrap; cursor: pointer; box-shadow: var(--shadow); background: #fff; color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.act .act-ic { font-size: 18px; line-height: 1; }
.act.primary { background: var(--accent); color: #fff; }
.act.on { background: var(--accent); color: #fff; }
.act:active { transform: scale(0.97); }

/* 提示/弹层 */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(45,30,55,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 99; }
.overlay { position: fixed; inset: 0; background: rgba(40,25,55,.45); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 80; padding: 20px; }
.overlay[hidden] { display: none; }
.card-panel { background: #fff; border-radius: 24px; padding: 22px; width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow); }
.card-panel h3 { margin: 0 0 8px; color: var(--accent); }
.card-panel p { margin: 4px 0 16px; color: #7a6a82; font-weight: 600; }
.card-panel .btn { width: 100%; border: none; border-radius: 14px; padding: 13px; font-weight: 800; font-size: 15px; cursor: pointer; background: var(--accent); color: #fff; margin-top: 8px; }
.card-panel .btn.ghost { background: #fff; color: var(--accent); border: 2px solid #e6d6f0; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.gallery .g { aspect-ratio: 3/4; background: #f6eefb; border-radius: 12px; overflow: hidden; }
.gallery .g svg { width: 100%; height: 100%; }

/* iPad / 横屏：一屏左右布局 */
@media (min-width: 760px), (orientation: landscape) {
  .app { flex-direction: row; }
  .preview { flex: 1; order: 1; }
  .side { order: 2; width: 392px; max-width: 44vw; display: flex; flex-direction: column; height: 100%; }
  .topbar { order: 0; position: absolute; top: 0; left: 0; right: 392px; z-index: 5; }
  .panel { border-radius: 0; flex: 1; overflow-y: auto; }
  .items { flex-wrap: wrap; overflow-x: hidden; }
}
