﻿/* Prep tab — doll + dual storage */

.prep-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: var(--sp-2);
  overflow: hidden;
}

.prep-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 6px 10px;
  min-height: 40px;
  border-bottom: 1px solid var(--line-1);
  flex-shrink: 0;
}

.prep-section-head h3 {
  margin: 0;
  font-size: var(--fs-h3);
  font-weight: var(--fw-b);
  white-space: nowrap;
}

.prep-head-left {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
}

.prep-toolbar {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.prep-toolbar button.active,
.prep-toolbar .btn-ghost.active {
  border-color: var(--line-focus);
  background: rgba(124, 92, 255, 0.22);
  color: #fff;
}

.prep-meta {
  font-size: var(--fs-cap);
  color: var(--text-3);
  white-space: nowrap;
}

.prep-hero-name-inline {
  font-size: var(--fs-body);
  font-weight: var(--fw-b);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* —— 上区：人偶定高；仓库同尺寸覆盖，不再撑大 —— */
.prep-top {
  position: relative;
  flex: 0 0 auto;
  flex-shrink: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  overflow: hidden;
}

.prep-top.is-wh {
  flex: 0 0 auto;
}

.prep-top-stage {
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
}

.prep-doll-body {
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.prep-doll-body.is-placeholder,
.prep-empty-tip.is-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.prep-wh-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px 10px;
  background: var(--surface-0);
  box-sizing: border-box;
}

.prep-doll-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  box-sizing: border-box;
}

.prep-skill-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  flex: 0 0 52px;
  padding: 2px 0;
}

.prep-skill-slot {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  border: 1px dashed rgba(53, 215, 255, 0.28);
  background: rgba(53, 215, 255, 0.06);
  display: grid;
  place-items: center;
  place-content: center;
  overflow: hidden;
  padding: 4px 3px 14px;
  box-sizing: border-box;
  cursor: pointer;
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.prep-skill-slot:active { transform: scale(0.96); }
.prep-skill-slot.filled {
  border-style: solid;
  border-color: rgba(53, 215, 255, 0.45);
  background: rgba(53, 215, 255, 0.14);
}
.prep-skill-slot.is-ultimate.filled {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.14);
}
.prep-skill-slot.is-small.filled {
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(167, 139, 250, 0.14);
}
.prep-skill-slot-name {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--text);
}
.prep-skill-slot-empty {
  font-size: 12px;
  color: var(--text-4);
  font-weight: 600;
}
.prep-skill-slot-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  text-align: center;
  font-size: 9px;
  line-height: 1.2;
  color: var(--text-3);
  pointer-events: none;
}

.equip-doll {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  grid-template-rows: 56px 56px 56px 56px;
  grid-template-areas:
    ". helmet ."
    "weapon body armor"
    "gloves body legs"
    "acc1 acc2 acc3";
  gap: 8px 10px;
  align-items: center;
  justify-items: center;
  flex: 1 1 auto;
  max-width: 280px;
  min-width: 0;
}

.equip-doll-body {
  width: 100%;
  height: 100%;
  min-height: 120px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--line-1);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.equip-doll-figure {
  transform: scale(0.72);
  transform-origin: center center;
}

.equip-slot {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line-2);
  background: var(--surface-1);
  display: grid;
  place-items: center;
  place-content: center;
  overflow: hidden;
  padding-bottom: 14px;
  box-sizing: border-box;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  cursor: pointer;
  --rar: var(--rar-normal);
}

.equip-slot:active {
  transform: scale(0.96);
}

.equip-slot.filled {
  border-style: solid;
  border-color: color-mix(in srgb, var(--rar) 45%, transparent);
  background: color-mix(in srgb, var(--rar) 12%, var(--surface-1));
}

.equip-slot-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  text-align: center;
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 1;
}

.equip-slot-img {
  width: 62%;
  height: 62%;
  max-height: 28px;
  object-fit: contain;
  pointer-events: none;
  margin-top: -4px;
}

.equip-slot-emoji {
  font-size: 20px;
  line-height: 1;
  margin-top: -4px;
}

.equip-slot-sil {
  font-size: 16px;
  line-height: 1;
  opacity: 0.35;
  margin-top: -4px;
}

.equip-slot-dot {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rar);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.prep-stat-brief {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.prep-stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: var(--r-sm);
  background: var(--surface-1);
  border: 1px solid var(--line-1);
}

.prep-stat-chip-label {
  font-size: var(--fs-micro);
  color: var(--text-3);
}

.prep-stat-chip-value {
  font-size: var(--fs-body);
  font-weight: var(--fw-b);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.prep-drag-hint {
  flex-shrink: 0;
  text-align: center;
  font-size: var(--fs-sub);
  font-weight: var(--fw-b);
  color: var(--accent);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: rgba(53, 215, 255, 0.1);
  border: 1px solid rgba(53, 215, 255, 0.28);
}

/* —— 下区：吃掉角色区以外的剩余高度 —— */
.prep-bottom {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  overflow: hidden;
}

/* 矮屏：略压缩人偶格，优先保证角色区仍完整可见 */
@media (max-height: 740px) {
  .prep-doll-row { max-width: 380px; gap: 6px; }
  .prep-skill-col { flex-basis: 44px; gap: 5px; }
  .prep-skill-slot { width: 44px; height: 44px; }
  .equip-doll {
    grid-template-columns: 48px 1fr 48px;
    grid-template-rows: repeat(4, 48px);
    gap: 6px 8px;
    max-width: 260px;
  }
  .equip-slot {
    width: 48px;
    height: 48px;
    padding-bottom: 12px;
  }
  .equip-doll-body {
    min-height: 100px;
  }
  .prep-doll-body {
    padding: 8px 8px 12px;
  }
  .equip-slot-label {
    font-size: 9px;
  }
}

@media (max-height: 640px) {
  .prep-doll-row { max-width: 340px; gap: 4px; }
  .prep-skill-col { flex-basis: 40px; gap: 4px; }
  .prep-skill-slot { width: 40px; height: 40px; padding-bottom: 11px; }
  .prep-skill-slot-name { font-size: 9px; }
  .equip-doll {
    grid-template-columns: 44px 1fr 44px;
    grid-template-rows: repeat(4, 44px);
    gap: 4px 6px;
    max-width: 240px;
  }
  .equip-slot {
    width: 44px;
    height: 44px;
    padding-bottom: 11px;
  }
  .equip-doll-body {
    min-height: 88px;
  }
  .equip-doll-figure {
    transform: scale(0.62);
  }
  .prep-stat-chip {
    padding: 4px 2px;
  }
}

.prep-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 10px;
  -webkit-overflow-scrolling: touch;
}

.prep-bag-zone {
  min-height: 120px;
}

.prep-empty-tip {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-body);
}

.prep-drop-zone {
  outline: 2px dashed rgba(105, 219, 124, 0.45);
  outline-offset: -3px;
  background: rgba(105, 219, 124, 0.06);
}

.prep-item-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px 6px;
  width: 100%;
  box-sizing: border-box;
}

.prep-item-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.prep-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-sizing: border-box;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: border-color var(--t-fast), transform var(--t-fast);
  overflow: hidden;
}

.prep-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 8px 0 0;
  border-color: var(--rar, var(--line-2)) transparent transparent transparent;
  opacity: 0.85;
}

.prep-item:active {
  cursor: grabbing;
  transform: scale(0.96);
}

.prep-item.selected {
  border-color: rgba(124, 92, 255, 0.85);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.4);
}

.prep-item.drag-over {
  border-color: rgba(105, 219, 124, 0.9);
  background: rgba(105, 219, 124, 0.16);
  transform: scale(1.04);
}

.prep-item-icon {
  font-size: 28px;
  line-height: 1;
}

.prep-item-img {
  width: 70%;
  height: 70%;
  max-width: 52px;
  max-height: 52px;
  object-fit: contain;
  pointer-events: none;
}

.prep-item-qty {
  position: absolute;
  right: 3px;
  bottom: 3px;
}

.prep-item-name {
  margin-top: 4px;
  width: 100%;
  font-size: var(--fs-micro);
  line-height: 1.25;
  text-align: center;
  color: var(--text-2);
}

/* 批量底栏 */
.batch-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-safe-h, var(--tabbar-h)) + 8px);
  z-index: var(--z-sheet);
  width: min(var(--app-w), calc(100% - 24px));
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 10px;
  border-radius: var(--r-lg);
  background: var(--panel);
  border: 1px solid var(--line-focus);
  box-shadow: var(--sh-2);
  font-size: var(--fs-sub);
  font-weight: var(--fw-b);
}

.batch-bar > span {
  flex: 1;
  min-width: 0;
  color: var(--text-2);
}

.prep-panel:has(+ *) {
  /* spacer when batch bar visible handled by padding on home-page via class if needed */
}

html:has(.home-page),
body:has(.home-page) {
  overflow: hidden;
  height: 100%;
}

/* 物品详情标签（保留） */
.prep-item-tags,
.item-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  width: 100%;
  margin-top: 3px;
}

.item-detail-tags {
  margin-top: 8px;
}

.item-tag.tag-material {
  color: #8ce99a;
  background: rgba(140, 233, 154, 0.12);
  border: 1px solid rgba(140, 233, 154, 0.25);
}
.item-tag.tag-weapon {
  color: #74c0fc;
  background: rgba(116, 192, 252, 0.1);
  border: 1px solid rgba(116, 192, 252, 0.25);
}
.item-tag.tag-armor {
  color: #b197fc;
  background: rgba(177, 151, 252, 0.1);
  border: 1px solid rgba(177, 151, 252, 0.25);
}
.item-tag.tag-gloves,
.item-tag.tag-legs,
.item-tag.tag-helmet {
  color: #91a7ff;
  background: rgba(145, 167, 255, 0.1);
  border: 1px solid rgba(145, 167, 255, 0.25);
}
.item-tag.tag-accessory {
  color: #ffd43b;
  background: rgba(255, 212, 59, 0.08);
  border: 1px solid rgba(255, 212, 59, 0.22);
}
.item-tag.tag-skill {
  color: #63e6be;
  background: rgba(99, 230, 190, 0.08);
  border: 1px solid rgba(99, 230, 190, 0.22);
}
