.refp-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: #1a1b1e;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: none;
}

[data-module="reference-prompt"] {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.panel-block > [data-module="reference-prompt"] {
  height: 100%;
}

.refp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.refp-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #f2f2fa;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}

.refp-badge {
  display: none;
}

.refp-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.refp-drop {
  position: relative;
  border: 1px dashed rgba(255,255,255,0.25);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  padding: 14px;
  text-align: center;
  color: #d9dcef;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.refp-drop:hover {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.03);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}

.refp-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.refp-drop strong {
  color: #f6f7ff;
}

.refp-drop small {
  display: block;
  margin-top: 6px;
  color: #9fa3c1;
}

.refp-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  grid-auto-rows: auto;
  gap: 10px;
}

/* Typed media slots keep their selected cards inside the owning slot instead
   of one ambiguous list below all upload controls. */
.refp-media-group__selection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 112px));
  align-items: start;
  justify-content: start;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.refp-media-group__selection:empty { display: none; }
.refp-media-group__selection .refp-item { min-width: 0; }

.refp-drop-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.refp-drop-block .refp-pick-resources {
  align-self: center;
  margin-top: -4px;
}

.refp-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #dbe7ef;
  min-height: 120px;
}
.refp-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: #f92ab7;
  border-radius: 50%;
  animation: refp-spin 1s linear infinite;
}
@keyframes refp-spin {
  to { transform: rotate(360deg); }
}

.refp-item {
  position: relative;
  /* padding-top trick instead of aspect-ratio for old WebView compat */
  height: 0;
  padding-top: 100%;
  overflow: hidden;
  border-radius: 8px;
  background: #0d0d0d;
  border: 1px solid rgba(255,255,255,0.12);
  box-sizing: content-box;
}

.refp-item--audio {
  height: auto;
  min-height: 190px;
  padding-top: 0;
  box-sizing: border-box;
}

.refp-item--audio .refp-reference-tag {
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refp-item--error {
  height: auto;
  min-height: 156px;
  padding-top: 0;
  overflow: visible;
  box-sizing: border-box;
  grid-column: 1 / -1;
}

.refp-item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.refp-item--uploading {
  opacity: 0.9;
}
.refp-uploading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(16,22,31,0.85), rgba(27,35,47,0.92));
}
.refp-uploading-text {
  color: #dbe7ef;
  font-size: 13px;
}

/* Loading overlay shown while a saved reference thumbnail is being fetched */
.refp-thumb-loading {
  z-index: 1;
  pointer-events: none;
  background: rgba(9, 9, 16, 0.85);
}

.refp-index {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 3px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: #f6f6ff;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.15);
}

.refp-thumb {
  /* Inherits position:absolute from .refp-item img */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.refp-preview-note {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(6, 8, 14, 0.75);
  color: #b8c0d6;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.refp-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(20,20,28,0.75);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s, transform 0.16s;
}

.refp-remove:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.refp-replace {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(20,20,28,0.75);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s, transform 0.16s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
}

.refp-replace:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

/* Shared gallery preview action. The behavior is owned by
   AIDC_REFERENCE_GALLERY_CONTRACT; ReferencePrompt owns only card geometry. */
.refp-gallery-preview {
  position: absolute;
  top: 6px;
  left: 38px;
  width: 26px;
  height: 26px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: transform 0.16s;
}
.refp-gallery-preview svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}
.refp-gallery-preview:hover {
  transform: translateY(-1px);
}

/* Reload preview button — shown on saved cards when preview fails to load */
.refp-reload-preview {
  position: absolute;
  bottom: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(20,20,28,0.75);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.16s, transform 0.16s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  padding: 0;
}
.refp-reload-preview:hover {
  background: rgba(100,120,255,0.55);
  transform: translateY(-1px);
}

.refp-prompt {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 0;
  min-width: 0;
}

.refp-textarea-shell {
  position: relative;
  min-width: 0;
}

.refp-textarea-shell .refp-textarea {
  display: block;
  padding-bottom: 52px;
}

.refp-textarea-shell .refp-translate-en-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  border-color: rgba(84, 210, 255, 0.4);
  background: rgba(13, 33, 49, 0.94);
  color: #9deaff;
}

.refp-translation-preview {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(84, 210, 255, 0.3);
  border-radius: 12px;
  background: rgba(13, 33, 49, 0.72);
  color: #e8f8ff;
}

.refp-translation-preview[hidden] {
  display: none;
}

.refp-translation-preview__title {
  color: #9deaff;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.refp-translation-preview__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.55;
}

.refp-translation-preview__note {
  color: #aebdca;
  line-height: 1.4;
}

.refp-label {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  /* allow actions to wrap to next line when container is too narrow */
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  font-size: 12px;
  color: #b3b6d1;
  letter-spacing: 0.04em;
}

.refp-label-text {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  /* keep the label text from pushing actions out of view: truncate with ellipsis */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refp-label-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  /* prefer no shrinking for action buttons so they remain visible */
  flex: 0 0 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.refp-label-actions .smart-prompt-btn,
.refp-label-actions .refp-icon-btn {
  flex: 0 0 auto;
}

.refp-label-actions .refp-expand-btn {
  margin-left: 0;
}

.refp-action-label {
  display: none;
}

@media (max-width: 560px) {
  .refp-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .refp-label-text,
  .refp-label-actions {
    width: 100%;
  }

  .refp-label-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    gap: 6px;
  }

  .refp-label-actions .smart-prompt-btn {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    margin-left: 0;
    padding: 6px 4px;
    justify-content: center;
    gap: 4px;
    font-size: clamp(9px, 2.7vw, 11px);
    line-height: 1.05;
    text-align: center;
  }

  .refp-label-actions .smart-prompt-btn svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
  }

  .refp-label-actions .refp-smart-prompt-primary {
    grid-column: auto;
  }

  .refp-label-actions .refp-expand-btn {
    display: none;
  }

  .refp-action-label {
    display: inline;
    white-space: normal;
  }
}

.refp-textarea {
  width: 100%;
  min-height: 240px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  color: #f3f5ff;
  padding: 12px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.refp-textarea:focus {
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

.refp-prompt-limit {
  margin-top: 7px;
  font-size: 12px;
  color: rgba(255,255,255,.56);
  text-align: right;
}

.refp-prompt-limit.is-warning { color: #f4be62; }
.refp-prompt-limit.is-error { color: #ff6b7a; font-weight: 600; }
.refp-textarea[aria-invalid="true"] { border-color: rgba(255,80,105,.75); }

/* ── Expand prompt button ───────────────────────────────────── */
.refp-expand-btn {
  margin-left: auto; /* push to the right end of the label row */
}

/* ── Expand prompt modal ────────────────────────────────────── */
.refp-expand-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: refpModalFadeIn 0.22s ease;
}
@keyframes refpModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.refp-expand-modal__container {
  display: flex;
  flex-direction: column;
  width: min(96vw, 820px);
  height: min(88vh, 720px);
  background: #181a26;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 0, 140, 0.08);
  overflow: hidden;
  animation: refpModalSlideUp 0.25s ease;
}
@keyframes refpModalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.refp-expand-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.refp-expand-modal__title {
  font-size: 15px;
  font-weight: 600;
  color: #f0f2ff;
  letter-spacing: 0.02em;
}

.refp-expand-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(240, 242, 255, 0.72);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s, box-shadow 0.18s;
}
.refp-expand-modal__close:hover {
  border-color: rgba(255, 0, 140, 0.50);
  background: rgba(255, 0, 140, 0.08);
  color: #ff008c;
  box-shadow: 0 0 14px rgba(255, 0, 140, 0.22);
}

.refp-expand-modal__textarea {
  flex: 1 1 auto;
  width: 100%;
  padding: 18px 20px;
  border: none;
  outline: none;
  background: transparent;
  color: #f3f5ff;
  font-size: 15px;
  line-height: 1.65;
  resize: none;
  font-family: inherit;
  overflow-y: auto;
}
.refp-expand-modal__textarea::placeholder {
  color: rgba(179, 182, 209, 0.45);
}
.refp-expand-modal__textarea::-webkit-scrollbar {
  width: 6px;
}
.refp-expand-modal__textarea::-webkit-scrollbar-track {
  background: transparent;
}
.refp-expand-modal__textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 3px;
}

.refp-expand-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.refp-expand-modal__counter {
  font-size: 12px;
  color: rgba(179, 182, 209, 0.50);
  font-variant-numeric: tabular-nums;
}

.refp-expand-modal__done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 22px;
  border-radius: 12px;
  border: 1px solid rgba(255, 0, 140, 0.45);
  background: rgba(255, 0, 140, 0.10);
  color: #ff5cad;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, color 0.18s;
}
.refp-expand-modal__done:hover {
  background: rgba(255, 0, 140, 0.18);
  border-color: rgba(255, 0, 140, 0.65);
  color: #ff79bf;
  box-shadow: 0 0 18px rgba(255, 0, 140, 0.30);
}

/* Mobile: full-screen modal */
@media (max-width: 600px) {
  .refp-expand-modal__container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
}

/* Toolbar row between file-list and prompt: shows count + clear button */
.refp-list-toolbar {
  display: flex;
  align-items: center;
  align-content: flex-start;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  padding: 4px 0 10px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.refp-list-toolbar:empty,
.refp-list-toolbar:not(:has(> *:not([style*="display: none"]):not([style*="display:none"]))) {
  display: none;
}

.refp-list-toolbar > * {
  flex: 0 1 auto;
  max-width: 100%;
}

.refp-list-toolbar + .refp-prompt {
  margin-top: 6px;
}

.refp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.refp-hint {
  font-size: 12px;
  color: #9aa0be;
}

.refp-btn {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  width: 100%;
  display: block;
  text-align: center;
  color: #f5f6ff;
  background: linear-gradient(120deg, #4a5166, #2f3646);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
  transition: transform 0.12s, box-shadow 0.18s, filter 0.18s;
  position: relative;
}

.refp-btn.is-hidden {
  display: none;
}

.refp-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(0,0,0,0.4);
}

.refp-btn:disabled {
  filter: grayscale(0.4);
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 10px 16px rgba(0,0,0,0.3);
}

.refp-btn[data-tokens]::after {
  content: " ⚡ " attr(data-tokens);
  font-weight: 900;
  color: #f5f6ff;
  text-shadow: 0 0 10px rgba(255,255,255,0.6);
}

.refp-item-error {
  width: 100%;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  color: #ffb4b4;
  background: rgba(180,30,30,0.06);
  border: 1px dashed rgba(255,100,100,0.12);
  padding: 14px 42px 14px 14px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-align: left;
  box-sizing: border-box;
}

.refp-audio {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
}

.refp-audio-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 38px;
}

.refp-audio-waveform > i {
  width: 3px;
  min-height: 4px;
  border-radius: 3px;
  background: linear-gradient(180deg, #70e7ff, #ef49b4);
  opacity: 0.9;
}

.refp-audio-meta {
  color: #a9bad0;
  font: 600 11px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.refp-audio-edit {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 42px;
  z-index: 4;
  border: 1px solid rgba(255, 77, 178, 0.5);
  border-radius: 7px;
  background: rgba(61, 21, 48, 0.92);
  color: #ff9fd5;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refp-retry {
  margin: 6px 8px 6px 8px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg,#2b6bff,#1f4fd6);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.refp-retry:disabled { opacity: 0.6; cursor: default; }

.refp-error-hint {
  font-size: 12px;
  color: #ffd7d7;
  margin-top: 6px;
}
.refp-error-meta {
  font-size: 11px;
  color: #ffefef;
  margin-top: 6px;
  opacity: 0.9;
}

.refp-count {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: #b3b6d1;
  min-width: 0;
}

.refp-bad {
  color: #ffb9c9;
}

/* Manage errors button (visible when there are errored refs) */
.refp-manage-errors {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: linear-gradient(120deg, #4a5166, #2f3646);
  color: #f5f6ff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
  transition: transform 0.12s, box-shadow 0.18s, filter 0.18s;
}
.refp-manage-errors:hover { transform: translateY(-1px); box-shadow: 0 14px 24px rgba(0,0,0,0.4); }

/* Clear all refs button */
.refp-clear-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 90, 90, 0.25);
  background: rgba(255, 60, 60, 0.10);
  color: #ff7b7b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.refp-clear-all:hover {
  background: rgba(255, 60, 60, 0.22);
  color: #ff5a5a;
  transform: translateY(-1px);
}
.refp-clear-all:active {
  transform: translateY(0);
  background: rgba(255, 60, 60, 0.30);
}

/* ── Midjourney extra reference slots (sref / oref) with sw/ow sliders ── */
.rp-mj-extra {
  margin: 12px 0 8px;
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.rp-mj-extra__title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.rp-mj-extra__group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.rp-mj-extra__group:last-child {
  margin-bottom: 0;
}
.rp-mj-extra__slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-height: 52px;
  position: relative;
}
.rp-mj-extra__slot:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.05);
}
.rp-mj-extra__slot.is-dragover {
  border-color: rgba(99, 102, 241, 0.7);
  background: rgba(99, 102, 241, 0.1);
}
.rp-mj-extra__slot.has-file {
  border-style: solid;
  border-color: rgba(99, 102, 241, 0.3);
}
.rp-mj-extra__slot.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.6);
}
.rp-mj-extra__icon {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1;
}
.rp-mj-extra__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rp-mj-extra__label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}
.rp-mj-extra__sublabel {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
}
.rp-mj-extra__preview {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
}
.rp-mj-extra__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rp-mj-extra__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.9);
  border: 2px solid #0b0b14;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.rp-mj-extra__slot.has-file .rp-mj-extra__remove {
  display: flex;
}
.rp-mj-extra__error {
  color: #f87171;
  font-size: 11px;
}
.rp-mj-extra__slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px;
}
.rp-mj-extra__slider-wrap.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}
.rp-mj-extra__slider-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.02em;
}
.rp-mj-extra__slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rp-mj-extra__range {
  flex: 1;
  height: 3px;
  appearance: none;
  background: linear-gradient(90deg, rgba(90,140,255,0.35), rgba(255,120,200,0.32));
  border-radius: 999px;
  outline: none;
  padding: 0;
}
.rp-mj-extra__range::-webkit-slider-thumb {
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f4ff6a;
  border: 1.5px solid #0b0b14;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
  cursor: pointer;
}
.rp-mj-extra__range::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f4ff6a;
  border: 1.5px solid #0b0b14;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
  cursor: pointer;
}
.rp-mj-extra__slider-value {
  font-size: 12px;
  color: #d8dcff;
  min-width: 36px;
  text-align: right;
}
.rp-mj-extra__hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  padding: 6px 0 2px;
  font-style: italic;
}

/* ── sref multi-image support ── */
.rp-mj-extra__multi-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.rp-mj-extra__multi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}
.rp-mj-extra__multi-grid:empty {
  display: none;
}
.rp-mj-extra__thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: visible;
  flex: 0 0 auto;
}
.rp-mj-extra__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.rp-mj-extra__thumb-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.9);
  border: 2px solid #0b0b14;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  padding: 0;
}
.rp-mj-extra__thumb-remove:hover {
  background: #ef4444;
}
.rp-mj-extra__add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px dashed rgba(99, 102, 241, 0.35);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.06);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.rp-mj-extra__add-btn:hover {
  border-color: rgba(99, 102, 241, 0.6);
  background: rgba(99, 102, 241, 0.12);
  color: rgba(255, 255, 255, 0.8);
}
.rp-mj-extra__add-btn svg {
  opacity: 0.6;
}

/* ─── Inline Template Picker (used when resources.js is not loaded) ─── */
.refp-tpl-picker {
  position: fixed; inset: 0; z-index: 100000;
  display: flex; align-items: center; justify-content: center;
}
.refp-tpl-picker__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
}
.refp-tpl-picker__card {
  position: relative; z-index: 1;
  width: min(420px, 90vw); max-height: 70vh;
  background: #1a1c2e; border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.refp-tpl-picker__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: 600; font-size: 15px; color: #e4e8f8;
}
.refp-tpl-picker__close {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 18px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.refp-tpl-picker__close:hover { color: #fff; background: rgba(255,255,255,0.08); }
.refp-tpl-picker__list {
  overflow-y: auto; padding: 8px;
  flex: 1 1 auto;
}
.refp-tpl-picker__item {
  display: flex; flex-direction: column; gap: 4px;
  width: 100%; text-align: left;
  padding: 10px 14px; border: none; border-radius: 8px;
  background: transparent; color: #e4e8f8;
  font-family: inherit; font-size: 13px; cursor: pointer;
  transition: background 0.15s;
}
.refp-tpl-picker__item:hover { background: rgba(143,179,255,0.10); }
.refp-tpl-picker__item strong {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.refp-tpl-picker__item span {
  color: rgba(228,232,248,0.5); font-size: 12px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
