.pc-image-modal-open { overflow: hidden; }

.pc-image-upload-button {
  display: inline-flex;
  height: 40px;
  margin-left: 12px;
  padding: 0 15px;
  align-items: center;
  gap: 7px;
  border: 1px solid #8fb7ef;
  border-radius: 9px;
  color: #1768df;
  background: #fff;
  font: 700 13px/1 "Microsoft YaHei", sans-serif;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.pc-image-upload-button:hover { border-color: #1768df; background: #f1f7ff; box-shadow: 0 5px 14px rgba(23, 104, 223, .1); }
.pc-image-upload-button-icon { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 6px; color: #fff; background: linear-gradient(145deg, #63a7ff, #1768df); font-size: 11px; }

#pc-image-upload {
  position: fixed;
  z-index: 10030;
  inset: 0;
  color: #17253b;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: auto;
  text-rendering: optimizeLegibility;
}
.pc-image-backdrop { position: absolute; inset: 0; background: rgba(16, 28, 48, .56); backdrop-filter: blur(3px); }
.pc-image-dialog { position: absolute; inset: 5vh 0 auto; width: min(960px, calc(100vw - 40px)); height: min(760px, 90vh); margin: 0 auto; overflow: hidden; border: 1px solid #d5dfec; border-radius: 18px; background: #f6f8fb; box-shadow: 0 30px 88px rgba(10, 25, 49, .3); }
.pc-image-dialog > header { display: flex; height: 78px; padding: 0 22px; align-items: center; gap: 12px; box-sizing: border-box; border-bottom: 1px solid #e1e8f1; background: #fff; }
.pc-image-title-icon { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 11px; color: #fff; background: linear-gradient(145deg, #63a7ff, #1768df); box-shadow: 0 7px 18px rgba(23, 104, 223, .2); font-size: 16px; font-weight: 800; }
.pc-image-dialog h2 { margin: 0; color: #13233a; font-size: 18px; }
.pc-image-dialog header p { margin: 4px 0 0; color: #78889d; font-size: 12px; }
.pc-image-close { width: 36px; height: 36px; margin-left: auto; border: 0; border-radius: 9px; color: #738399; background: #f1f4f8; font-size: 24px; line-height: 34px; cursor: pointer; }
.pc-image-close:hover { color: #1d2b40; background: #e7ecf3; }
.pc-image-body { height: calc(100% - 78px); }

.pc-image-editor { display: grid; height: 100%; grid-template-rows: 62px minmax(0, 1fr) 82px; }
.pc-image-editor-bar { display: flex; padding: 0 20px; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f1; background: #fff; }
.pc-image-editor-bar > div { display: flex; align-items: baseline; gap: 11px; }
.pc-image-editor-bar b { font-size: 14px; }
.pc-image-editor-bar span { color: #7a8a9f; font-size: 12px; }

.pc-image-grid { display: grid; padding: 18px; align-content: start; align-items: start; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); grid-auto-rows: max-content; gap: 14px; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.pc-image-card { position: relative; display: grid; min-width: 0; min-height: 238px; height: auto; overflow: hidden; grid-template-rows: 142px minmax(57px, auto) 38px; align-self: start; border: 1px solid #d9e2ee; border-radius: 12px; background: #fff; box-shadow: 0 5px 14px rgba(37, 58, 87, .05); cursor: grab; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.pc-image-card:hover { border-color: #a7c8f5; box-shadow: 0 8px 20px rgba(33, 94, 176, .1); }
.pc-image-card.is-dragging { opacity: .45; transform: scale(.97); }
.pc-image-card.is-dragover { border-color: #1768df; box-shadow: 0 0 0 3px rgba(23, 104, 223, .14); }
.pc-image-number { position: absolute; z-index: 2; top: 8px; left: 8px; display: grid; width: 27px; height: 27px; place-items: center; border-radius: 8px; color: #fff; background: #1768df; box-shadow: 0 3px 9px rgba(23, 104, 223, .28); font-size: 12px; font-weight: 800; }
.pc-image-drag { position: absolute; z-index: 2; top: 8px; right: 8px; display: grid; width: 27px; height: 27px; place-items: center; border-radius: 8px; color: #52647b; background: rgba(255, 255, 255, .92); box-shadow: 0 2px 8px rgba(20, 35, 54, .12); font-size: 16px; letter-spacing: -3px; }
.pc-image-thumb { width: 100%; height: 142px; min-height: 142px; overflow: hidden; background: linear-gradient(45deg, #edf1f6 25%, transparent 25%), linear-gradient(-45deg, #edf1f6 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #edf1f6 75%), linear-gradient(-45deg, transparent 75%, #edf1f6 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; }
.pc-image-thumb img { width: 100%; height: 100%; object-fit: contain; background: rgba(255, 255, 255, .72); pointer-events: none; }
.pc-image-card-copy { display: flex; min-height: 57px; padding: 8px 11px 6px; box-sizing: border-box; flex-direction: column; gap: 3px; }
.pc-image-card-copy strong { display: -webkit-box; min-height: 32px; overflow: hidden; color: #25364d; font-size: 12px; line-height: 16px; white-space: normal; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.pc-image-card-copy small { color: #8795a8; font-size: 10px; }
.pc-image-card-actions { display: grid; height: 38px; padding: 0 9px 9px; box-sizing: border-box; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pc-image-card-actions button { height: 29px; border: 1px solid #dce4ef; border-radius: 7px; color: #61738a; background: #f8fafc; font-size: 14px; cursor: pointer; }
.pc-image-card-actions button:hover:not(:disabled) { border-color: #9fc2f2; color: #1768df; background: #eef6ff; }
.pc-image-card-actions button:disabled { opacity: .35; cursor: not-allowed; }
.pc-image-card-actions button.is-remove { color: #d94b57; }

.pc-image-empty { display: flex; min-height: 390px; align-items: center; justify-content: center; grid-column: 1 / -1; flex-direction: column; color: #8391a4; }
.pc-image-empty > span { display: grid; width: 70px; height: 70px; margin-bottom: 15px; place-items: center; border-radius: 20px; color: #4f94ef; background: #eaf3ff; font-size: 34px; }
.pc-image-empty b { color: #35465d; font-size: 15px; }
.pc-image-empty p { margin: 7px 0 18px; font-size: 12px; }

.pc-image-footer { display: flex; padding: 0 20px; align-items: center; gap: 20px; border-top: 1px solid #dfe6ef; background: #fff; color: #6c7d92; font-size: 12px; }
.pc-image-footer > span { margin-left: auto; white-space: nowrap; }
.pc-image-footer > span b { color: #1768df; font-size: 16px; }
.pc-image-name { display: flex; width: min(390px, 42vw); align-items: center; gap: 10px; }
.pc-image-name label { flex: 0 0 auto; color: #44566e; font-size: 12px; font-weight: 700; }
.pc-image-name input { width: 100%; height: 38px; padding: 0 12px; box-sizing: border-box; border: 1px solid #d6e0ec; border-radius: 8px; outline: none; color: #24364e; font: 12px/1 "Microsoft YaHei", sans-serif; }
.pc-image-name input:focus { border-color: #1768df; box-shadow: 0 0 0 3px rgba(23, 104, 223, .1); }

.pc-image-primary, .pc-image-secondary { height: 40px; padding: 0 17px; border-radius: 9px; font: 700 12px/38px "Microsoft YaHei", sans-serif; cursor: pointer; white-space: nowrap; }
.pc-image-primary { border: 1px solid #1768df; color: #fff; background: #1768df; box-shadow: 0 6px 15px rgba(23, 104, 223, .16); }
.pc-image-secondary { border: 1px solid #b8d0ef; color: #1768df; background: #fff; }
.pc-image-primary:disabled { border-color: #b9c6d7; background: #b9c6d7; box-shadow: none; cursor: not-allowed; }

.pc-image-progress-state, .pc-image-result { display: flex; height: 100%; padding: 30px; box-sizing: border-box; align-items: center; justify-content: center; flex-direction: column; text-align: center; }
.pc-image-progress-icon { display: grid; width: 62px; height: 62px; place-items: center; border-radius: 18px; background: #eaf3ff; }
.pc-image-progress-icon i { width: 27px; height: 27px; border: 3px solid #bfd7f7; border-top-color: #1768df; border-radius: 50%; animation: pc-image-spin .8s linear infinite; }
@keyframes pc-image-spin { to { transform: rotate(360deg); } }
.pc-image-progress-state h3, .pc-image-result h3 { margin: 18px 0 8px; font-size: 20px; }
.pc-image-progress-state p, .pc-image-result p { max-width: 520px; margin: 0 0 22px; overflow: hidden; color: #73849a; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.pc-image-progress { width: min(480px, 70vw); height: 8px; overflow: hidden; border-radius: 999px; background: #e1e8f1; }
.pc-image-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #66aaff, #1768df); transition: width .15s linear; }
.pc-image-progress-state > strong { margin-top: 10px; color: #1768df; font-size: 17px; }
.pc-image-progress-state > small { margin-top: 5px; color: #8795a8; font-size: 11px; }
.pc-image-result > span { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; color: #fff; background: #21aa6b; font-size: 28px; font-weight: 800; }
.pc-image-result.is-error > span { background: #e7515d; }

@media (max-width: 820px) {
  .pc-image-upload-button { margin-left: 0; }
  .pc-image-dialog { inset: 16px 0 auto; width: calc(100vw - 24px); height: calc(100vh - 32px); }
  .pc-image-dialog > header { height: 70px; padding: 0 14px; }
  .pc-image-body { height: calc(100% - 70px); }
  .pc-image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px; gap: 9px; }
  .pc-image-footer { min-height: 116px; padding: 10px 12px; flex-wrap: wrap; gap: 9px; }
  .pc-image-name { width: 100%; }
  .pc-image-footer > span { margin-left: 0; }
  .pc-image-footer .pc-image-primary { margin-left: auto; }
  .pc-image-editor { grid-template-rows: 58px minmax(0, 1fr) auto; }
}

/* Keep every card readable when many images are selected. The grid scrolls;
   cards no longer collapse to fit all rows inside the dialog. */
#pc-image-upload .pc-image-grid {
  grid-auto-rows: max-content !important;
  align-content: start !important;
  align-items: start !important;
}
#pc-image-upload .pc-image-card {
  display: grid !important;
  min-height: 238px !important;
  height: auto !important;
  grid-template-rows: 142px minmax(57px, auto) 38px !important;
  align-self: start !important;
}
#pc-image-upload .pc-image-thumb {
  width: 100% !important;
  height: 142px !important;
  min-height: 142px !important;
}
#pc-image-upload .pc-image-thumb img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}
#pc-image-upload .pc-image-card-copy {
  display: flex !important;
  min-height: 57px !important;
  visibility: visible !important;
  opacity: 1 !important;
}
#pc-image-upload .pc-image-card-actions {
  display: grid !important;
  height: 38px !important;
  visibility: visible !important;
  opacity: 1 !important;
}

@media (prefers-reduced-motion: reduce) {
  .pc-image-card, .pc-image-progress i, .pc-image-upload-button { transition: none; }
}
