:root {
  --primary: #2d2b55;
  --primary-light: #4a47a3;
  --accent: #5b57d1;
  --bg: #f0f0f7;
  --card: #ffffff;
  --ink: #1a1a2e;
  --muted: #8888a0;
  --line: #e4e4ef;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column;
}
.hidden { display: none !important; }

/* Top Bar */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px; background: var(--primary); color: #fff; flex-shrink: 0;
}
.top-bar h1 { font-size: 18px; font-weight: 700; }
.params-bar { display: flex; gap: 14px; align-items: center; }
.params-bar label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: rgba(255,255,255,.8); }
.params-bar select {
  border: 1px solid rgba(255,255,255,.2); border-radius: 6px;
  padding: 3px 8px; font: inherit; font-size: 13px;
  background: rgba(255,255,255,.1); color: #fff; outline: none;
}
.params-bar select option { color: var(--ink); background: #fff; }
.cb-label { cursor: pointer; }

/* Split */
.split { display: flex; flex: 1; min-height: 0; }
/* Left Panel */
.left {
  width: 260px; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 20px; gap: 6px;
  overflow-y: auto; background: #fff;
  border-right: 1px solid var(--line);
}
.section-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; margin-top: 10px; }
.section-label:first-child { margin-top: 0; }

/* Model Picker (compact) */
.model-picker {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; cursor: pointer; transition: border-color .2s;
}
.model-picker:hover { border-color: var(--accent); }
.picker-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 8px 0; }
.picker-selected { display: flex; align-items: center; gap: 10px; }
.picker-avatar { width: 44px; height: 58px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.picker-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.picker-name { font-size: 15px; font-weight: 700; color: var(--primary); }
.picker-style { font-size: 12px; color: var(--accent); }
.picker-change { font-size: 12px; color: var(--accent); flex-shrink: 0; }

/* Garment Upload */
.garment-row { display: flex; gap: 10px; }
.garment-box {
  flex: 1; height: 130px;
  border: 2px dashed var(--line); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; position: relative;
}
.garment-box:hover { border-color: var(--accent); }
.garment-ph { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.g-icon { font-size: 20px; }
.garment-img { width: 100%; height: 100%; object-fit: contain; display: none; }

/* Generate */
#generate {
  width: 100%; margin-top: auto;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px;
  padding: 14px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .2s;
}
#generate:hover { background: var(--primary-light); }
#generate:disabled { opacity: .6; cursor: not-allowed; }

/* Right Panel */
.right {
  flex: 1; display: flex; flex-direction: column;
  padding: 24px; min-width: 0; overflow-y: auto;
  background: var(--bg);
}
.right-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.result-item {
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s;
}
.result-item:hover { transform: translateY(-2px); }
.result-item img {
  width: 100%; display: block; cursor: pointer;
  border-radius: var(--radius);
}

/* Loading skeleton */
.skeleton-item {
  border-radius: var(--radius);
  overflow: hidden; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.skeleton-inner {
  width: 100%; aspect-ratio: 3/4;
  background: linear-gradient(110deg, #f0f0f5 30%, #e8e8f0 50%, #f0f0f5 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Modal */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff; border-radius: 16px;
  width: 780px; max-width: 92vw; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.modal-head {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; color: var(--primary); margin: 0; white-space: nowrap; }
.modal-close {
  margin-left: auto; border: none; background: none;
  font-size: 24px; color: var(--muted); cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--ink); }
.tabs { display: flex; gap: 0; }
.tab {
  padding: 6px 16px; border: none; background: none;
  font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .2s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--accent); font-weight: 600; }
.tab:hover { color: var(--primary); }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }

/* Modal Grid */
.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.model-card {
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 12px; cursor: pointer; transition: all .15s;
  display: flex; gap: 10px; position: relative;
}
.model-card:hover { border-color: var(--primary-light); }
.model-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91,87,209,.18); }
.model-card .m-img {
  width: 90px; object-fit: contain; border-radius: 8px; flex-shrink: 0;
  align-self: center;
}
.model-card .m-body { display: flex; flex-direction: column; justify-content: center; }
.model-card .m-name { font-size: 16px; font-weight: 700; color: var(--primary); }
.model-card .m-style { font-size: 13px; color: var(--accent); margin: 2px 0 6px; }
.model-card .m-info { font-size: 12px; color: var(--muted); line-height: 1.7; }
.model-card .m-dot {
  position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); background: #fff;
}
.model-card.selected .m-dot { border-color: var(--accent); background: var(--accent); }

/* Custom Upload in Modal */
.custom-upload {
  width: 180px; height: 240px;
  border: 2px dashed var(--line); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; position: relative;
}
.custom-upload:hover { border-color: var(--accent); }
.custom-ph { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.custom-img { width: 100%; height: 100%; object-fit: cover; display: none; }

/* Scrollbar */
.left::-webkit-scrollbar, .right::-webkit-scrollbar, .modal-body::-webkit-scrollbar { width: 5px; }
.left::-webkit-scrollbar-thumb, .right::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.1); border-radius: 3px;
}
