* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: #2b2350; overflow: hidden; background: #1c1533;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }

/* ================= 整体：左舞台 / 右衣柜 ================= */
.app { position: relative; height: 100%; display: flex; align-items: stretch; }

/* ---------------- 舞台（左） ---------------- */
.stage { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #1c1533; }
.scene { position: absolute; inset: -3%; width: 106%; height: 106%; object-fit: cover;
  transition: opacity .5s ease; will-change: transform; }
.scene.fading { opacity: .25; }
.scene-veil { position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(80% 55% at 50% 30%, rgba(255,255,255,.06), transparent 65%),
    linear-gradient(180deg, rgba(12,8,28,.45) 0%, transparent 22%, transparent 70%, rgba(12,8,28,.42) 100%);
  box-shadow: inset 0 0 120px rgba(10, 6, 24, .5); }

/* 人物（带底座阴影 + 多层动态） */
.figure-wrap { position: absolute; z-index: 3; will-change: transform; }
.figure { position: relative; height: 100%; aspect-ratio: 9 / 16; cursor: pointer; outline: none;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 18px 22px rgba(10, 6, 24, .35));
  animation: feiyu-idle 5.4s ease-in-out infinite; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transition: opacity .3s ease; user-select: none; -webkit-user-drag: none;
  animation: feiyu-breathe 4.6s ease-in-out infinite; }
.layer.fading { opacity: .15; }
.figure-shadow { position: absolute; left: 50%; bottom: -2.5%; width: 64%; height: 4.2%;
  transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(8, 5, 20, .5), rgba(8, 5, 20, 0) 72%);
  filter: blur(2px); z-index: -1; }

@keyframes feiyu-idle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-9px) rotate(.7deg); }
}
@keyframes feiyu-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}
.figure.hop { animation: feiyu-hop .62s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes feiyu-hop {
  0% { transform: translateY(0) rotate(0); }
  35% { transform: translateY(-26px) rotate(-2deg); }
  70% { transform: translateY(3px) rotate(1deg); }
  100% { transform: translateY(0) rotate(0); }
}
.figure.pop .layer { animation: feiyu-pop .38s ease-out; }
@keyframes feiyu-pop {
  0% { opacity: .4; transform: scale(.985); }
  100% { opacity: 1; transform: scale(1); }
}

.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

.bubble { position: absolute; z-index: 6; top: 8%; left: 50%; transform: translateX(-50%);
  max-width: 70%; padding: 9px 15px; border-radius: 16px; background: rgba(255,255,255,.94);
  color: #3b2f63; font-size: 13.5px; font-weight: 700; line-height: 1.5; text-align: center;
  box-shadow: 0 10px 26px rgba(40, 20, 90, .22); animation: pop-in .22s ease-out; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px;
  background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
@keyframes pop-in { from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(.94); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }

.brand-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; color: #fff; }
.brand { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600;
  text-shadow: 0 1px 3px rgba(10, 5, 30, .85), 0 2px 12px rgba(10, 5, 30, .6); }
.brand b { font-weight: 800; letter-spacing: .5px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .22); border: 1px solid rgba(255, 255, 255, .3); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.36);
  background: rgba(255,255,255,.18); color: #fff; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  text-decoration: none; backdrop-filter: blur(10px); transition: transform .15s, background .15s; }
.icon-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.3); }
.icon-btn.light { background: rgba(122,100,220,.12); color: #4a3f78; border-color: transparent; }

.stage-tip { position: absolute; z-index: 5; left: 50%; bottom: 10px; transform: translateX(-50%);
  font-size: 11.5px; color: rgba(255,255,255,.85); text-shadow: 0 1px 6px rgba(0,0,0,.5);
  white-space: nowrap; transition: opacity .6s ease; pointer-events: none; }
.stage-tip.gone { opacity: 0; }
.stage-credit { position: absolute; z-index: 5; left: 10px; bottom: 6px; font-size: 9.5px;
  color: rgba(255,255,255,.62); text-shadow: 0 1px 4px rgba(0,0,0,.55);
  pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%; }
body.embed .stage-credit { display: none; }
body.embed .brand-bar { display: none; }

/* ---------------- 衣柜（右） ---------------- */
.wardrobe { position: relative; z-index: 10; flex: 0 0 clamp(300px, 31vw, 400px);
  display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(165deg, rgba(253, 249, 255, .96), rgba(243, 238, 255, .94));
  box-shadow: -14px 0 40px rgba(30, 16, 66, .28);
  padding: 14px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
.wardrobe-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.shape-toggle { display: flex; gap: 4px; padding: 3px; border-radius: 999px;
  background: rgba(122, 100, 220, .1); border: 1px solid rgba(122, 100, 220, .18); }
.shape-btn { border: 0; background: transparent; color: #6a5acd; font-size: 12.5px;
  font-weight: 800; padding: 6px 14px; border-radius: 999px; cursor: pointer; transition: all .16s ease; }
.shape-btn.active { background: linear-gradient(135deg, #a58bff, #6fc8ff); color: #fff;
  box-shadow: 0 4px 12px rgba(120, 100, 220, .35); }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; border: 1.5px solid transparent; background: rgba(122, 100, 220, .08);
  color: #5b4b8f; font-size: 12.5px; font-weight: 800; padding: 6px 12px; border-radius: 999px;
  cursor: pointer; transition: all .16s ease; }
.tab:hover { background: rgba(122, 100, 220, .16); }
.tab.active { color: #fff; background: linear-gradient(135deg, #a58bff, #6fc8ff);
  box-shadow: 0 6px 16px rgba(120, 100, 220, .35); }

.grid { flex: 1; min-height: 0; overflow-y: auto; display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; align-content: start;
  padding: 2px 2px 8px; scrollbar-width: thin; scrollbar-color: rgba(122,100,220,.35) transparent; }
.grid::-webkit-scrollbar { width: 5px; }
.grid::-webkit-scrollbar-thumb { background: rgba(122,100,220,.3); border-radius: 999px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px 5px;
  border: 2px solid transparent; border-radius: 16px; cursor: pointer;
  background: linear-gradient(160deg, rgba(255,255,255,.92), rgba(244,236,255,.9));
  box-shadow: 0 4px 12px rgba(120, 100, 200, .12);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.item:hover { transform: translateY(-2px); }
.item.active { border-color: #9a7cf0; box-shadow: 0 8px 20px rgba(154, 124, 240, .38); }
.item img { width: 100%; aspect-ratio: 1; border-radius: 12px; object-fit: contain;
  background: radial-gradient(circle at 50% 45%, #fdfaff, #f1e9ff); pointer-events: none; }
.item.bg img { object-fit: cover; }
.item span { font-size: 10.5px; font-weight: 800; color: #4a3f78; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .emoji { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 30px; border-radius: 12px; background: radial-gradient(circle at 50% 45%, #fdfaff, #f1e9ff); }

.wardrobe-foot { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px;
  padding-top: 10px; border-top: 1px solid rgba(122, 100, 220, .14); }
.meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.meta #lookName { font-size: 14px; font-weight: 800; color: #3b2f63;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta #lookDesc { font-size: 11px; color: #7a6ea6;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btns { display: flex; gap: 8px; }
.btn { flex: 1; border: 0; border-radius: 14px; padding: 11px 10px; font-size: 13px; font-weight: 800;
  cursor: pointer; color: #4a3f78; background: rgba(122, 100, 220, .1);
  transition: transform .15s ease, box-shadow .15s ease; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.98); }
.btn.primary { color: #fff; background: linear-gradient(135deg, #a58bff, #6fc8ff);
  box-shadow: 0 8px 20px rgba(120, 100, 220, .3); }

/* ---------------- 图鉴 ---------------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: rgba(22, 14, 45, .5); backdrop-filter: blur(6px); }
.sheet-card { width: min(720px, 100%); max-height: 84vh; overflow: auto; border-radius: 22px;
  background: #fdfbff; padding: 16px 16px 20px; box-shadow: 0 24px 60px rgba(20, 10, 50, .4); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet-stat { font-size: 12px; color: #7a6ea6; margin-bottom: 12px; }
.sheet-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.sheet-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px;
  border-radius: 14px; background: linear-gradient(160deg, #fff, #f3ecff); }
.sheet-item img { width: 100%; aspect-ratio: 1; object-fit: contain;
  background: radial-gradient(circle at 50% 45%, #fdfaff, #f1e9ff); border-radius: 12px; }
.sheet-item span { font-size: 11px; font-weight: 700; color: #4a3f78; text-align: center; }
.sheet-section { grid-column: 1 / -1; font-size: 12.5px; font-weight: 800; color: #6a5acd; margin-top: 6px; }
.sheet-credit { grid-column: 1 / -1; font-size: 10.5px; color: #9a8fc0; line-height: 1.6; margin-top: 10px; }

/* ---------------- 窄屏 / 嵌入 ---------------- */
body.embed .wardrobe { flex-basis: clamp(280px, 34vw, 380px); }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .stage { flex: 1 1 auto; min-height: 0; }
  .wardrobe { flex: 0 0 auto; height: 44vh; max-height: 380px;
    border-radius: 22px 22px 0 0; box-shadow: 0 -14px 40px rgba(30, 16, 66, .3);
    padding: 12px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .brand-bar { padding: 10px 12px; }
  .stage-credit { display: none; }
}
@media (max-width: 820px) and (max-height: 700px) {
  .wardrobe { height: 40vh; }
}
@media (prefers-reduced-motion: reduce) {
  .figure, .layer { animation: none !important; }
  .scene, .layer { transition: none !important; }
}
