/* PeeperFrog User Portal — scoped styles */

.pfup-app,
.pfup-modal,
.pfup-progress-modal,
.pfup-toast {
  --pfup-bg:       #ffffff;
  --pfup-surface:  #f5f6f8;
  --pfup-border:   #d0d4dc;
  --pfup-text:     #111111;
  --pfup-muted:    #555e70;
  --pfup-primary:  #4a44e0;
  --pfup-success:  #16a34a;
  --pfup-danger:   #dc2626;
  --pfup-warning:  #b45309;
  --pfup-radius:   8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.pfup-app {
  max-width: 540px;
  margin: 0 auto;
  padding: 1.5rem;
  color: var(--pfup-text);
  background: var(--pfup-bg);
}

.pfup-app[data-app="user-badge"] {
  background: transparent;
  padding: 0;
  max-width: none;
  margin: 0;
}

.pfup-loading { color: var(--pfup-muted); padding: 2rem; text-align: center; }

/* Card */
.pfup-card {
  background: var(--pfup-bg);
  border: 1px solid var(--pfup-border);
  border-radius: var(--pfup-radius);
  padding: 2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.pfup-card-title {
  margin: 0 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--pfup-text);
}

/* Form elements */
.pfup-field { margin-bottom: 1rem; }
.pfup-field label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--pfup-muted);
  margin-bottom: .35rem;
}
.pfup-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: .55rem .8rem;
  background: #fff;
  border: 1px solid var(--pfup-border);
  border-radius: var(--pfup-radius);
  font-size: .9rem;
  color: var(--pfup-text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.pfup-input:focus {
  border-color: var(--pfup-primary);
  box-shadow: 0 0 0 3px rgba(74,68,224,.12);
}
.pfup-input[readonly] { background: var(--pfup-surface); cursor: default; }
select.pfup-input { cursor: pointer; }
.pfup-hint { font-size: .8rem; color: var(--pfup-muted); margin-top: .3rem; }

/* Buttons */
.pfup-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: 1px solid var(--pfup-border);
  border-radius: var(--pfup-radius);
  background: #fff;
  color: var(--pfup-text);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.pfup-btn:hover { background: #111; border-color: #111; color: #fff; }
.pfup-btn-primary  { background: var(--pfup-primary); border-color: var(--pfup-primary); color: #fff; }
.pfup-btn-primary:hover  { background: #111; border-color: #111; color: #fff; }
.pfup-btn-danger   { background: #fef2f2; border-color: #fca5a5; color: var(--pfup-danger); }
.pfup-btn-danger:hover   { background: #111; border-color: #111; color: #fff; }
.pfup-btn-secondary { background: var(--pfup-surface); border-color: var(--pfup-border); color: var(--pfup-text); }
.pfup-btn-secondary:hover { background: #111; border-color: #111; color: #fff; }
.pfup-btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.pfup-btn:disabled { opacity: .5; cursor: not-allowed; }

.pfup-btn-row {
  display: flex;
  gap: .6rem;
  margin-top: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Alerts */
.pfup-alert {
  padding: .8rem 1rem;
  border-radius: var(--pfup-radius);
  font-size: .875rem;
  margin-bottom: 1rem;
}
.pfup-alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: var(--pfup-danger); }
.pfup-alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--pfup-success); }
.pfup-alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.pfup-alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: var(--pfup-warning); }

/* API key display */
.pfup-key-box {
  background: #0f172a;
  color: #7dd3fc;
  border-radius: var(--pfup-radius);
  padding: 1rem 1.25rem;
  font-family: 'Courier New', monospace;
  font-size: .9rem;
  word-break: break-all;
  position: relative;
  margin: .75rem 0;
}
.pfup-key-copy-btn {
  position: absolute;
  top: .6rem;
  right: .6rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  border-radius: 4px;
  padding: .2rem .5rem;
  font-size: .75rem;
  cursor: pointer;
}
.pfup-key-copy-btn:hover { background: rgba(255,255,255,.2); }

/* Section dividers */
.pfup-section-title {
  font-size: .75rem;
  font-weight: 700;
  color: var(--pfup-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-top: 1px solid var(--pfup-border);
  margin: 1.5rem 0 1rem;
  padding-top: .75rem;
}

/* Badges */
.pfup-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.pfup-tier-free       { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.pfup-tier-paid       { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.pfup-tier-enterprise { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }

/* Table for service keys / WP sites */
.pfup-item-list { list-style: none; margin: 0; padding: 0; }
.pfup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: 1px solid var(--pfup-border);
  font-size: .875rem;
  gap: .5rem;
}
.pfup-item:last-child { border-bottom: none; }
.pfup-item-label { font-weight: 600; }
.pfup-item-sub   { color: var(--pfup-muted); font-size: .8rem; }
.pfup-item-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* Nav/header bar inside account */
.pfup-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--pfup-border);
}
.pfup-topbar-name { font-weight: 700; font-size: 1rem; }
.pfup-topbar-tier { margin-left: .5rem; }

/* Modal */
.pfup-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  overflow-y: auto;
}
.pfup-modal-box {
  background: var(--pfup-bg);
  border-radius: var(--pfup-radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  margin: auto;
}
.pfup-modal-title {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Toast */
.pfup-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: .7rem 1.1rem;
  border-radius: var(--pfup-radius);
  font-size: .875rem;
  font-weight: 500;
  z-index: 10000;
  animation: pfup-fadein .2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.pfup-toast-success { background: #15803d; color: #fff; }
.pfup-toast-error   { background: var(--pfup-danger); color: #fff; }

@keyframes pfup-fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Signup key reveal screen */
.pfup-key-reveal {
  text-align: center;
  padding: .5rem 0;
}
.pfup-key-reveal-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.pfup-key-reveal h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
.pfup-key-reveal p  { color: var(--pfup-muted); font-size: .9rem; margin: 0 0 1rem; }

/* Full-width apps */
.pfup-app[data-app="explorer"],
.pfup-app[data-app="preview"] {
  max-width: none;
}

/* Password strength rules */
.pfup-pw-rules {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .75rem;
  margin-top: .4rem;
}
.pfup-pwr {
  font-size: .78rem;
  color: var(--pfup-danger, #dc2626);
}
.pfup-pwr-ok {
  color: var(--pfup-success, #15803d);
}

/* Bulk operation progress modal */
.pfup-progress-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 10001;
  padding: 1rem;
  overflow-y: auto;
}
.pfup-progress-box {
  background: var(--pfup-bg);
  border-radius: var(--pfup-radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: auto;
}
.pfup-progress-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--pfup-text);
}
.pfup-progress-bar-track {
  height: 8px;
  background: var(--pfup-surface);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: .5rem;
}
.pfup-progress-bar-fill {
  height: 100%;
  background: var(--pfup-primary);
  border-radius: 99px;
  width: 0%;
  transition: width .2s ease;
}
.pfup-progress-count {
  font-size: .8rem;
  color: var(--pfup-muted);
  margin-bottom: .4rem;
}
.pfup-progress-file {
  font-size: .8rem;
  color: var(--pfup-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1rem;
  min-height: 1.2em;
}

/* ── File Explorer ─────────────────────────────────────────────────────────── */

.pfup-explorer { width: 100%; }

.pfup-explorer-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}

.pfup-breadcrumb {
  flex: 1;
  font-size: .85rem;
  color: var(--pfup-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pfup-bc-item {
  color: var(--pfup-primary);
  cursor: pointer;
}
.pfup-bc-item:hover { text-decoration: underline; }
.pfup-bc-sep { color: var(--pfup-muted); margin: 0 .2rem; }

.pfup-rate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem 1.5rem;
  margin-bottom: .5rem;
}
@media (max-width: 540px) {
  .pfup-rate-grid { grid-template-columns: 1fr; }
}
.pfup-rate-row { display: flex; flex-direction: column; gap: .2rem; }
.pfup-rate-label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--pfup-text);
}
.pfup-rate-nums { color: var(--pfup-muted); white-space: nowrap; }
.pfup-rate-pct  { font-weight: 600; }
.pfup-rate-warn {
  margin-top: .5rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  font-size: .8rem;
}

.pfup-quota-bar-wrap { margin-bottom: 1rem; }
.pfup-quota-bar-track {
  height: 8px;
  background: var(--pfup-surface);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: .3rem;
}
.pfup-quota-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .3s ease;
}
.pfup-quota-label { font-size: .78rem; color: var(--pfup-muted); }

.pfup-file-items { margin: 0; padding: 0; list-style: none; }

.pfup-select-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: var(--pfup-radius);
  margin-bottom: .4rem;
  flex-wrap: wrap;
  font-size: .85rem;
}
.pfup-check-wrap { width: 1.25rem; flex-shrink: 0; display: flex; align-items: center; }
.pfup-file-check { cursor: pointer; width: 1rem; height: 1rem; accent-color: var(--pfup-primary); }
.pfup-file-item.pfup-selected { background: #eff2ff; border-radius: var(--pfup-radius); }
.pfup-select-all-row { border-bottom: 1px solid var(--pfup-border); background: var(--pfup-surface); }

.pfup-file-item { align-items: center; }
.pfup-file-info {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.pfup-file-icon { flex-shrink: 0; font-style: normal; }
.pfup-file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.pfup-file-size {
  font-size: .78rem;
  color: var(--pfup-muted);
  flex-shrink: 0;
  margin-left: .4rem;
}

/* ── Explorer toolbar and view toggle ─────────────────────────────────────── */

.pfup-explorer-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.pfup-view-toggle { display: flex; gap: .2rem; margin-left: .15rem; }

.pfup-btn.pfup-active {
  background: var(--pfup-primary);
  color: #fff;
  border-color: var(--pfup-primary);
}

/* ── Grid (thumbnail) view ──────────────────────────────────────────────── */

.pfup-grid-select-all-row {
  padding: .3rem .5rem;
  border-bottom: 1px solid var(--pfup-border);
  margin-bottom: .5rem;
  font-size: .85rem;
  color: var(--pfup-muted);
  display: flex;
  align-items: center;
  gap: .4rem;
}

.pfup-file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
  padding: .25rem 0 .5rem;
}

.pfup-grid-cell {
  position: relative;
  border: 2px solid transparent;
  border-radius: var(--pfup-radius);
  background: var(--pfup-surface);
  overflow: visible;
  transition: border-color .15s;
}

.pfup-grid-cell.pfup-selected { border-color: var(--pfup-primary); }
.pfup-grid-cell:hover { border-color: var(--pfup-border); }
.pfup-grid-cell.pfup-selected:hover { border-color: var(--pfup-primary); }

.pfup-grid-thumb-wrap {
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
  overflow: hidden;
  border-radius: calc(var(--pfup-radius) - 2px) calc(var(--pfup-radius) - 2px) 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pfup-grid-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pfup-grid-folder-icon { font-size: 2.75rem; line-height: 1; user-select: none; }

.pfup-grid-name {
  font-size: .78rem;
  padding: .3rem .4rem .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  font-weight: 500;
}

/* Grid select checkbox — label+hidden-input+span pattern for reliable
   cross-browser/Android rendering. Label, input, and span are all the same
   size and stacked at the same position so the touch target matches exactly. */
.pfup-grid-check-lbl {
  position: absolute;
  top: .35rem;
  left: .35rem;
  z-index: 2;
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}
.pfup-grid-check-lbl input[type="checkbox"] {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.pfup-grid-check-box {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,.4);
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 3px;
  box-sizing: border-box;
  pointer-events: none;
}
.pfup-grid-check-lbl input[type="checkbox"]:checked + .pfup-grid-check-box {
  background: var(--pfup-primary);
  border-color: var(--pfup-primary);
}
.pfup-grid-check-lbl input[type="checkbox"]:checked + .pfup-grid-check-box::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: .32rem;
  height: .58rem;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: translate(-50%, -60%) rotate(45deg);
}

.pfup-grid-dir-actions {
  display: flex;
  gap: .25rem;
  padding: .2rem .3rem .3rem;
  justify-content: center;
}

/* ── Image Preview ─────────────────────────────────────────────────────────── */

.pfup-preview-widget { width: 100%; }

.pfup-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 2px dashed var(--pfup-border);
  border-radius: var(--pfup-radius);
  color: var(--pfup-muted);
  font-size: .875rem;
}

.pfup-preview-img-wrap { text-align: center; }
.pfup-preview-img { display: block; margin: 0 auto; }

.pfup-preview-caption {
  font-size: .8rem;
  color: var(--pfup-muted);
  margin-top: .5rem;
  word-break: break-all;
}

/* ── Reference Library Search ─────────────────────────────────────────────── */

.pfup-lib-search {
  width: 100%;
  max-width: none;
}

.pfup-lib-upgrade {
  text-align: center;
  padding: 3rem 2rem;
  border: 2px dashed var(--pfup-border);
  border-radius: var(--pfup-radius);
  color: var(--pfup-muted);
}
.pfup-lib-upgrade-icon { font-size: 3rem; margin-bottom: 1rem; }
.pfup-lib-upgrade p    { margin: 0 0 1.5rem; }

/* Toolbar */
.pfup-lib-toolbar    { margin-bottom: 1rem; }
.pfup-lib-search-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.pfup-lib-search-row .pfup-input { flex: 1 1 200px; }
.pfup-lib-bulk-row   { display: flex; align-items: center; gap: .75rem; margin-top: .6rem; font-size: .875rem; }
.pfup-lib-sel-all-label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.pfup-lib-status     { font-size: .8rem; color: var(--pfup-muted); margin-bottom: .5rem; }

/* License filter popover */
.pfup-lib-lic-wrap   { position: relative; }
.pfup-lib-lic-panel  {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--pfup-bg);
  border: 1px solid var(--pfup-border);
  border-radius: var(--pfup-radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: .6rem;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
}
.pfup-lib-lic-all   { display: flex; align-items: center; gap: .4rem; font-weight: 600; padding-bottom: .4rem; border-bottom: 1px solid var(--pfup-border); margin-bottom: .4rem; cursor: pointer; font-size: .875rem; }
.pfup-lib-lic-item  { display: flex; align-items: center; gap: .4rem; font-size: .8rem; padding: .2rem 0; cursor: pointer; }

/* Thumbnail grid */
.pfup-lib-grid {
  display: grid;
  grid-template-columns: repeat(var(--pfup-lib-cols, 5), 1fr);
  gap: .5rem;
}
.pfup-lib-item {
  position: relative;
  border-radius: var(--pfup-radius);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s;
}
.pfup-lib-item:hover          { box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.pfup-lib-item-selected       { border-color: var(--pfup-primary) !important; }
.pfup-lib-thumb-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--pfup-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pfup-lib-thumb-wrap img     { width: 100%; height: 100%; object-fit: cover; display: block; }
.pfup-lib-no-thumb           { font-size: 2rem; color: var(--pfup-border); }

/* Loading spinner */
.pfup-lib-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--pfup-border);
  border-top-color: var(--pfup-primary);
  border-radius: 50%;
  animation: pfup-spin .7s linear infinite;
  margin: auto;
}
.pfup-lib-spinner-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes pfup-spin { to { transform: rotate(360deg); } }

/* Checkbox overlay */
.pfup-lib-cb {
  position: absolute;
  top: .3rem;
  left: .3rem;
  width: 16px; height: 16px;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  transition: opacity .15s;
}
.pfup-lib-item:hover .pfup-lib-cb,
.pfup-lib-item-selected .pfup-lib-cb { opacity: 1; }

/* Saved (green checkmark) badge */
.pfup-lib-saved-badge {
  position: absolute;
  top: .25rem;
  right: .25rem;
  background: var(--pfup-success);
  color: #fff;
  border-radius: 50%;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  z-index: 2;
}
.pfup-lib-item-name {
  font-size: .7rem;
  color: var(--pfup-muted);
  padding: .2rem .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pagination */
.pfup-lib-pagination { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; }
.pfup-lib-pager-ellipsis { color: var(--pfup-muted); padding: 0 .2rem; font-size: .875rem; }

/* Popup overlay */
.pfup-lib-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.pfup-lib-popup {
  position: relative;
  background: var(--pfup-bg);
  border-radius: var(--pfup-radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  width: 960px;
  max-width: 98vw;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: auto;
}
.pfup-lib-popup-close {
  position: absolute;
  top: .5rem; right: .75rem;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--pfup-muted);
  z-index: 1;
  padding: .25rem .4rem;
  line-height: 1;
}
.pfup-lib-popup-close:hover { color: var(--pfup-text); }
.pfup-lib-popup-body {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  min-height: 0;
}
.pfup-lib-popup-img-wrap {
  flex: 1 1 60%;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  overflow: hidden;
  border-radius: var(--pfup-radius) 0 0 var(--pfup-radius);
}
.pfup-lib-popup-fullimg { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.pfup-lib-popup-meta {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--pfup-border);
  background: var(--pfup-bg, #fff);
  border-radius: 0 var(--pfup-radius) var(--pfup-radius) 0;
}
.pfup-lib-popup-meta-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem 1.25rem .75rem;
}
.pfup-lib-person-warning { font-size: .78rem; line-height: 1.45; padding: .55rem .7rem; border-radius: 5px; margin-bottom: .75rem; }
.pfup-lib-person-living        { background: #fff3cd; border-left: 3px solid #e6a817; color: #6b4a00; }
.pfup-lib-person-historical    { background: #e8f0fe; border-left: 3px solid #5a7ec7; color: #1e3a6e; }
.pfup-lib-person-face-detected { background: #f5f5f5; border-left: 3px solid #9e9e9e; color: #444; }
.pfup-lib-attr-required     { background: #f0fdf4; border-left: 3px solid #22c55e; color: #14532d; }
.pfup-upgrade-tier { background: #eff6ff; border-left: 3px solid #2563eb; color: #1e40af; padding: .75rem 1rem; border-radius: 0 6px 6px 0; font-size: .9rem; line-height: 1.5; }
.pfup-upgrade-tier a { color: #2563eb; font-weight: 600; }
.pfup-lib-quota { display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: flex-end; font-size: .78rem; color: var(--pfup-muted); padding: .5rem 0 0; border-top: 1px solid var(--pfup-border); margin-top: .75rem; }
.pfup-lib-quota strong { color: var(--pfup-text); }
.pfup-lib-popup-title { font-weight: 700; font-size: 1rem; margin-bottom: .75rem; overflow-wrap: break-word; word-break: normal; padding-right: 1.5rem; }
.pfup-lib-popup-section-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pfup-muted); margin-bottom: .3rem; margin-top: .1rem; }
.pfup-lib-popup-desc  { font-size: .85rem; color: var(--pfup-muted); margin: 0 0 .9rem; line-height: 1.5; }
.pfup-lib-popup-none  { font-style: italic; opacity: .5; }
.pfup-lib-popup-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .75rem;
  font-size: .8rem;
  margin-bottom: .75rem;
}
.pfup-lib-popup-dl dt { font-weight: 600; color: var(--pfup-muted); white-space: nowrap; }
.pfup-lib-popup-dl dd { margin: 0; word-break: break-word; }
.pfup-lib-popup-tags  { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .75rem; }
.pfup-lib-tag         { font-size: .7rem; background: var(--pfup-surface); border: 1px solid var(--pfup-border); border-radius: 99px; padding: .15rem .5rem; color: var(--pfup-muted); }
.pfup-lib-tag-match   { background: #fff3cd; border-color: #e6ac00; color: #7a5800; font-weight: 600; }
.pfup-match           { background: #fff3cd; color: #7a5800; border-radius: 2px; padding: 0 1px; font-style: normal; }
.pfup-lib-popup-actions {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .75rem 1.25rem 1rem;
  border-top: 1px solid var(--pfup-border);
  background: var(--pfup-bg, #fff);
}

/* Thumbnail shown in popup while full image is loading */
.pfup-lib-popup-placeholder { filter: blur(4px); transform: scale(1.04); transition: filter .3s, transform .3s; }

/* Empty-state hint shown before first search */
.pfup-lib-empty-hint { padding: 2rem 0; text-align: center; color: var(--pfup-muted, #555e70); font-size: .9rem; }

@media (max-width: 600px) {
  /* Two-zone mobile layout:
     - Image: fixed 45vh at top (explicit height anchors max-height:100% on the img)
     - Meta: takes remaining viewport space; description scrolls inside it
     - Action buttons: always pinned to bottom of the meta panel (flex-shrink:0 in base)
     The popup stays within the viewport — no overlay scrolling needed.
     height (not just max-height) is required so flex children can fill the popup. */
  .pfup-lib-popup-overlay { padding: 0.5rem; align-items: flex-start; }
  .pfup-lib-popup { height: calc(100vh - 1rem); max-height: calc(100vh - 1rem); }
  .pfup-lib-popup-body { flex-direction: column; }
  .pfup-lib-popup-img-wrap {
    flex: 0 0 45vh;
    height: 45vh;
    min-height: 0;
    border-radius: var(--pfup-radius) var(--pfup-radius) 0 0;
  }
  /* Meta fills the remaining ~55vh. flex:1 1 0 + min-height:0 lets it shrink
     to its allocated space instead of growing unbounded (flex:none). */
  .pfup-lib-popup-meta { flex: 1 1 0; min-height: 0; border-left: none; border-top: 1px solid var(--pfup-border); border-radius: 0 0 var(--pfup-radius) var(--pfup-radius); overflow: hidden; }
  /* Description/tags area scrolls within the meta panel. */
  .pfup-lib-popup-meta-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  /* Force explicit dimensions so object-fit:contain actually letterboxes the image
     instead of the browser's natural max-* aspect-ratio handling, which lets the
     image overflow the 45vh container and get clipped by overflow:hidden. */
  .pfup-lib-popup-fullimg { width: 100%; height: 100%; object-fit: contain; }
  .pfup-lib-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ── Alt Text Compliance ──────────────────────────────────────────────────── */
.pfup-hidden { display: none !important; }
.pfup-alt-compliance-warn {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--pfup-radius);
  padding: .65rem .85rem;
  font-size: .85rem;
  color: #795548;
  margin-bottom: .75rem;
}

/* ── User Badge ──────────────────────────────────────────────────────────── */
.pfup-badge {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .3rem .6rem;
  background: transparent;
  border: 1px solid var(--pfup-border);
  border-radius: var(--pfup-radius);
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
}

.pfup-badge-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--pfup-text);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
