/* ============================================================
  PopupWidget — 独立浮窗控件样式
  ============================================================ */

.pw-aihuihua.pw-overlay {
  display: none; position: fixed; inset: 0; z-index: 9000;
}
.pw-aihuihua.pw-overlay.pw-show { display: block; }

.pw-aihuihua.pw-popup {
  display: none; position: fixed; z-index: 9001;
  background: #1c1c1c; border: 1px solid #2d2d2d;
  border-radius: 10px; padding: 16px; min-width: 240px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
  animation: pw-pop-in 0.15s ease;
}
.pw-aihuihua.pw-popup.pw-show { display: block; }

@keyframes pw-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.pw-aihuihua .pw-popup-title {
  font-size: 11px; color: #666; letter-spacing: 0.8px;
  text-transform: uppercase; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

form .pw-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 20px;
  padding: 6px 14px; color: #cccccc; font-size: 13px; cursor: pointer;
  text-decoration: none; transition: background 0.2s, border-color 0.2s;
  white-space: nowrap; user-select: none;
}
form .pw-trigger:hover     { background: #252525; border-color: #ffffff; }
form .pw-trigger.pw-active { border-color: #ffffff; background: #2a2a2a; }
form .pw-trigger .pw-label { color: #999; font-size: 14px; }
form .pw-trigger .pw-value { color: #ffffff; font-weight: 600; }
form .pw-trigger .pw-arrow { color: #555; font-size: 10px; }

/* ── 比例网格 ── */
.pw-aihuihua .pw-ratio-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.pw-aihuihua .pw-ratio-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: 7px 8px; border-radius: 7px;
  cursor: pointer; transition: background 0.15s; min-width: 42px;
}
.pw-aihuihua .pw-ratio-item:hover,
.pw-aihuihua .pw-ratio-item.pw-selected { background: #2a2a2a; }
.pw-aihuihua .pw-ratio-icon {
  width: 26px; height: 20px; border: 1.5px solid #444; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s;
}
.pw-aihuihua .pw-ratio-item:hover       .pw-ratio-icon,
.pw-aihuihua .pw-ratio-item.pw-selected .pw-ratio-icon { border-color: #ffffff; }
.pw-aihuihua .pw-ratio-label { font-size: 12px; color: #fff; white-space: nowrap; }

.pw-aihuihua .pw-ratio-icon.pw-r-auto  { width:20px; height:20px; border-radius:10%; font-size:9px; color:#666; border:1px dotted #fff; }
.pw-aihuihua .pw-ratio-icon.pw-r-1_1   { width:20px; height:20px; }
.pw-aihuihua .pw-ratio-icon.pw-r-2_3   { width:16px; height:24px; }
.pw-aihuihua .pw-ratio-icon.pw-r-3_2   { width:24px; height:16px; }
.pw-aihuihua .pw-ratio-icon.pw-r-3_4   { width:18px; height:24px; }
.pw-aihuihua .pw-ratio-icon.pw-r-4_3   { width:26px; height:20px; }
.pw-aihuihua .pw-ratio-icon.pw-r-4_5   { width:20px; height:25px; }
.pw-aihuihua .pw-ratio-icon.pw-r-5_4   { width:25px; height:20px; }
.pw-aihuihua .pw-ratio-icon.pw-r-9_16  { width:15px; height:27px; }
.pw-aihuihua .pw-ratio-icon.pw-r-16_9  { width:28px; height:16px; }
.pw-aihuihua .pw-ratio-icon.pw-r-21_9  { width:32px; height:14px; }
.pw-aihuihua .pw-ratio-icon.pw-r-9_21  { width:14px; height:32px; }

/* ── 数字网格（张数） ── */
.pw-aihuihua .pw-count-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pw-aihuihua .pw-count-item {
  flex: 1; min-width: 40px; padding: 9px 0; border-radius: 7px;
  border: 1px solid #2d2d2d; background: #222; color: #ccc;
  font-size: 13px; font-weight: 600; cursor: pointer; text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s; user-select: none;
}
.pw-aihuihua .pw-count-item:hover,
.pw-aihuihua .pw-count-item.pw-selected { background: #2a2a2a; border-color: #ffffff; color: #ffffff; }

/* ── 列表选项 ── */
.pw-aihuihua .pw-list { display: flex; flex-direction: column; gap: 6px; }
.pw-aihuihua .pw-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 7px; border: 1px solid #2d2d2d;
  background: #222; cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.pw-aihuihua .pw-list-item:hover,
.pw-aihuihua .pw-list-item.pw-selected { background: #2a2a2a; border-color: #ffffff; }
.pw-aihuihua .pw-list-item .pw-item-name { font-size: 13px; color: #ccc; }
.pw-aihuihua .pw-list-item.pw-selected .pw-item-name { color: #ffffff; }
.pw-aihuihua .pw-list-item .pw-item-tag {
  font-size: 12px; padding: 2px 7px; border-radius: 10px;
  background: #2a2a2a; color: #ffffff; border: 1px solid #555;
}

/* ── Range 滑块 ── */
.pw-aihuihua .pw-range-wrap   { display: flex; flex-direction: column; gap: 8px; }
.pw-aihuihua .pw-range-header { display: flex; justify-content: space-between; align-items: baseline; }
.pw-aihuihua .pw-range-label-text { font-size: 12px; color: #777; }
.pw-aihuihua .pw-range-val { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.pw-aihuihua .pw-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: #3a3a3a; outline: none; cursor: pointer;
}
.pw-aihuihua .pw-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,0.5); transition: transform 0.15s;
}
.pw-aihuihua .pw-range::-webkit-slider-thumb:hover { transform: scale(1.2); }
.pw-aihuihua .pw-range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: none; cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
.pw-aihuihua .pw-range-minmax {
  display: flex; justify-content: space-between;
  font-size: 10px; color: #555; margin-top: -4px;
}

/* ── MJ 参数名小标签（如 --iw / --sref） ── */
.pw-mj-param {
  font-style: normal;
  font-size: 10px;
  color: #555;
  background: #252525;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.3px;
  text-transform: none;
}

/* ══════════════════════════════════════════════════════════════
   风格参考（sref）弹窗内部样式
══════════════════════════════════════════════════════════════ */

/* 已上传图片的预览区（弹窗内，flex wrap 横排） */
.pw-sref-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  /* 无图时高度为 0，有图时自然撑开 */
}

/* 单张 sref 预览卡片 */
.pw-sref-card {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid #333;
  background: #111;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.15s;
}
.pw-sref-card:hover { border-color: #fff; }

.pw-sref-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* 删除按钮（右上角） */
.pw-sref-del {
  position: absolute;
  top: -1px; right: -1px;
  width: 18px; height: 18px;
  border-radius: 0 6px 0 6px;
  background: rgba(229, 62, 62, 0.88);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.pw-sref-del:hover { background: #c53030; }

/* 上传按钮（弹窗底部） */
.pw-sref-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px dashed #444;
  border-radius: 8px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.pw-sref-upload-btn:hover {
  border-color: #fff;
  color: #fff;
  background: #222;
}
.pw-sref-upload-btn.pw-sref-upload-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.pw-sref-upload-icon {
  font-size: 18px;
  line-height: 1;
}

.pw-sref-upload-text {
  flex: 1;
}

/* 张数徽标（如 2/5） */
.pw-sref-badge {
  font-size: 10px;
  color: #666;
  background: #252525;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   图片卡片（垫图，主上传区）
══════════════════════════════════════════════════════════════ */
.img-card { position: relative; width: 72px; height: 72px; flex-shrink: 0; z-index: 1; }
.img-card.is-hovered { z-index: 500; }
.img-card .img-wrap {
  width: 72px; height: 72px; border-radius: 8px; border: 1px solid #333;
  background: #111; overflow: hidden; display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  transform-origin: bottom left; transition: none; position: relative; z-index: 1;
}
.img-card.is-hovered .img-wrap {
  transform: scale(2.8); box-shadow: 0 12px 40px rgba(0,0,0,0.75); border-color: #fff;
  transition: transform 0.38s cubic-bezier(0.34,1.2,0.64,1),
  box-shadow 0.38s ease, border-color 0.38s ease;
}
.img-card img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; display: block; pointer-events: none;
}
.img-card .del-btn {
  position: absolute; bottom: -6px; left: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #e53e3e; color: #fff; font-size: 11px;
  line-height: 18px; text-align: center; cursor: pointer;
  z-index: 10; border: 1.5px solid #161616; user-select: none;
  transition: background 0.15s;
}
.img-card .del-btn:hover { background: #c53030; }
.img-card .img-num {
  position: absolute; top: 4px; left: 4px; z-index: 10;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 12px;
  line-height: 1; padding: 2px 5px; border-radius: 4px;
  pointer-events: none; user-select: none; white-space: nowrap;
  transition: opacity 0.2s ease; opacity: 1;
}
.img-card.is-hovered .img-num { opacity: 0; }

/* ══════════════════════════════════════════════════════════════
   AIImageForm 表单组件专属样式（作用域：.pw-ai-form）
══════════════════════════════════════════════════════════════ */
#imgPreviewArea { }
.pw-ai-form .img-preview-area {
  display: none; bottom: calc(100% - 10px);
  z-index: 200; flex-wrap: wrap; gap: 10px; padding: 10px;
  position: absolute;
  border-top-right-radius: 10px;
  border-top-left-radius: 10px;
  backdrop-filter: blur(16px);
  background: #383A40;
}
.pw-ai-form .img-preview-area.has-images { display: flex; }

.pw-ai-form .input-row { display: flex; align-items: flex-start; gap: 10px; }

.pw-ai-form .upload-btn {
  flex-shrink: 0; width: 72px; height: 72px; border-radius: 10px;
  color: #888; font-size: 22px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  user-select: none; position: relative; margin-top: -35px;
}
.pw-ai-form .upload-btn:hover    { border-color: #fff; color: #fff; background: #222; }
.pw-ai-form .upload-btn.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.pw-ai-form .upload-btn.hidden   { display: none; }

.pw-ai-form .upload-badge {
  position: absolute; bottom: -6px; right: -6px;
  background: #333; color: #aaa; font-size: 9px; padding: 1px 4px;
  border-radius: 6px; border: 1px solid #444; white-space: nowrap; pointer-events: none;
}
.pw-ai-form .upload-badge.full { background: #2a1a1a; color: #e53e3e; border-color: #e53e3e; }

.pw-ai-form .prompt-textarea { padding: 0 5px; height: auto; }
#uploadBadge { display: none; }
.pw-ai-form .prompt-textarea:focus        { border-color: #555; }
.pw-ai-form .prompt-textarea::placeholder { color: #555; }

.pw-ai-form .toolbar-row {
  border-radius: 8px;
  padding: 8px 15px 1px 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pw-ai-form .sep { width: 1px; height: 20px; background: #2a2a2a; margin: 0 2px; }

/* ── 右侧图标按钮组 ── */
.pw-ai-form .toolbar-icon-group {
  margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding-right: 90px;
}
.pw-ai-form .toolbar-icon-btn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid #666;
  background: #383A40; color: #555; display: flex; align-items: center;
  justify-content: center; cursor: pointer; padding: 0; flex-shrink: 0;
  transition: border-color 0.18s, color 0.18s, background 0.18s; user-select: none;
}
.pw-ai-form .toolbar-icon-btn:hover { border-color: #fff; color: #fff; background: #222; }
.pw-ai-form .toolbar-icon-btn.active { border-color: #7c3aed; color: #a78bfa; background: #1e1230; }
.pw-ai-form .toolbar-icon-btn.active:hover { border-color: #fff; background: #251640; }
.pw-ai-form .toolbar-icon-btn.active svg.icon-bookmark { fill: currentColor; }
.pw-ai-form .toolbar-icon-btn.danger:hover { border-color: #e53e3e; color: #fc8181; background: #2a1010; }
#formButton { margin-right: -10px; margin-top: -45px; }

.pw-ai-form .model-hint {
  font-size: 12px; color: #999; padding: 0 2px 0; line-height: 1.6; letter-spacing: 0.2px;
}

.pw-ai-form .submit-btn {
  display: block; margin-top: 12px; padding: 10px;
  border: none; background: #7c3aed; color: #fff;
  font-size: 15px; cursor: pointer; margin-right: -10px;
}
.pw-ai-form .submit-btn:hover { background: #6d28d9; }