.pbm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 14, 0.62);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.pbm-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.pbm-dialog {
  width: min(1120px, 94vw);
  height: min(760px, 88vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(69, 72, 78, 0.22);
  background: #101419;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45), 0 0 60px rgba(255, 168, 79, 0.06);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s ease;
}

.pbm-overlay.active .pbm-dialog {
  transform: translateY(0) scale(1);
}

.pbm-header {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(69, 72, 78, 0.18);
  background: rgba(40, 44, 52, 0.28);
}

.pbm-title-wrap {
  display: flex;
  align-items: center;
  min-width: 120px;
}

.pbm-header-title {
  font-size: 14px;
  font-weight: 700;
  color: #f2f3f5;
}

.pbm-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.pbm-tool-btn,
.pbm-open-btn,
.pbm-chip-btn,
.pbm-mini-btn,
.pbm-menu-item {
  appearance: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pbm-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #a7b3c7;
  font-size: 13px;
}

.pbm-tool-btn:hover,
.pbm-open-btn:hover,
.pbm-chip-btn:hover,
.pbm-mini-btn:hover,
.pbm-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #eef4ff;
}

.pbm-tool-btn.accent {
  background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
  color: #fff7ec;
}

.pbm-tool-btn.icon-only {
  width: 34px;
  padding: 0;
}

.pbm-sort-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: #dce7f8;
  font-size: 13px;
  cursor: pointer;
}

.pbm-sort-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
}

.pbm-header-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.pbm-size-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #8190a7;
}

.pbm-size-control input[type="range"] {
  width: 92px;
}

.pbm-sort-select {
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: #dce7f8;
  font-size: 13px;
}

.pbm-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.pbm-sidebar {
  width: 168px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.12);
}

.pbm-sidebar-section {
  padding: 14px 10px 0;
}

.pbm-sidebar-section.grow {
  flex: 1;
  min-height: 0;
}

.pbm-group-section {
  min-height: 0;
}

.pbm-sidebar-caption {
  padding: 0 6px 8px;
  color: #8894aa;
  font-size: 12px;
  font-weight: 600;
}

.pbm-sidebar-caption-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pbm-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: auto;
}

.pbm-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #b4c0d4;
  text-align: left;
  font-size: 14px;
}

.pbm-sidebar-item.active {
  background: rgba(255,168,79, 0.16);
  color: #fff7ec;
}

.pbm-sidebar-item.drag-over,
.pbm-sidebar-list.drag-over {
  background: rgba(255,168,79, 0.12);
  outline: 1px dashed rgba(255,168,79, 0.5);
  outline-offset: -2px;
}

.pbm-sidebar-item.drag-insert-top,
.pbm-sidebar-item.drag-insert-bottom {
  position: relative;
}

.pbm-sidebar-item.drag-insert-top::before,
.pbm-sidebar-item.drag-insert-bottom::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 999px;
  background: #ffa84f;
  box-shadow: 0 0 0 1px rgba(255,168,79, 0.15), 0 0 10px rgba(255,168,79, 0.35);
}

.pbm-sidebar-item.drag-insert-top::before {
  top: -3px;
}

.pbm-sidebar-item.drag-insert-bottom::after {
  bottom: -3px;
}

.pbm-group-section.drag-over {
  background: rgba(255,168,79, 0.08);
  outline: 1px dashed rgba(255,168,79, 0.4);
  outline-offset: -6px;
  border-radius: 14px;
}

.pbm-sidebar-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pbm-sidebar-item-count {
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #97a5bb;
  font-size: 12px;
  text-align: center;
}

.pbm-sidebar-item.active .pbm-sidebar-item-count {
  background: rgba(255,168,79, 0.2);
  color: #fff7ec;
}

.pbm-mini-btn {
  padding: 0 8px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #95a2b9;
  font-size: 12px;
}

.pbm-sidebar-empty {
  padding: 10px 12px;
  color: #6f7d93;
  font-size: 12px;
}

.pbm-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.pbm-selection-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,168,79, 0.14);
  background: rgba(255,168,79, 0.08);
}

.pbm-selection-bar.visible {
  display: flex;
}

.pbm-selection-text {
  color: #fff7ec;
  font-size: 13px;
  font-weight: 600;
}

.pbm-selection-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pbm-chip-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #d8e4f6;
  font-size: 12px;
}

.pbm-chip-btn.danger,
.pbm-menu-item.danger {
  color: #ff9b9b;
}

.pbm-grid-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 18px;
}

.pbm-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pbm-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pbm-section-label {
  color: #8c9bb3;
  font-size: 13px;
  font-weight: 600;
}

.pbm-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(var(--pbm-thumb-size, 220px), 1fr));
}

.pbm-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.pbm-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.pbm-card.selected {
  border-color: rgba(255,168,79, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255,168,79, 0.2);
}

.pbm-card.current {
  box-shadow: inset 0 0 0 1px rgba(255,168,79, 0.24);
}

.pbm-overlay.is-dragging-projects .pbm-card.selected {
  opacity: 0.38;
  transform: scale(0.98);
  box-shadow: inset 0 0 0 1px rgba(255,168,79, 0.14);
}

.pbm-overlay.is-dragging-projects .pbm-card.selected .pbm-card-thumb,
.pbm-overlay.is-dragging-projects .pbm-card.selected .pbm-card-body {
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.pbm-overlay.is-dragging-projects .pbm-card.selected .pbm-card-thumb {
  transform: scale(0.995);
}

.pbm-overlay.is-dragging-projects .pbm-card.selected .pbm-card-body {
  opacity: 0.82;
}

.pbm-drag-preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99999;
  pointer-events: none;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255,168,79, 0.34);
  background: rgba(17, 24, 33, 0.94);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
  opacity: 0.96;
  transform: scale(1);
  transform-origin: top left;
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}

.pbm-drag-preview.is-compact {
  opacity: 0.98;
  transform: scale(0.56);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.pbm-drag-preview .pbm-card-thumb {
  aspect-ratio: auto;
  height: 62%;
}

.pbm-drag-preview .pbm-card-body {
  padding: 8px 10px 10px;
}

.pbm-drag-preview .pbm-card-name {
  font-size: 12px;
}

.pbm-drag-preview .pbm-card-meta,
.pbm-drag-preview .pbm-card-group,
.pbm-drag-preview .pbm-open-btn {
  font-size: 10px;
}

.pbm-drag-preview .pbm-card-fav,
.pbm-drag-preview .pbm-open-btn {
  pointer-events: none;
}

.pbm-drag-preview-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,168,79, 0.9);
  color: #eef4ff;
  font-size: 11px;
  font-weight: 700;
}

.pbm-card-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.025);
}

.pbm-card-thumb img,
.pbm-card-thumb video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.pbm-empty-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #6f7d93;
  font-size: 13px;
}

.pbm-card-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(10, 16, 24, 0.7);
  color: rgba(255, 255, 255, 0.72);
}

.pbm-card-fav.is-active {
  color: #ffd56a;
}

.pbm-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.pbm-card-name {
  color: #edf4ff;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pbm-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: #8493a9;
  font-size: 12px;
}

.pbm-card-badge {
  color: #6ea9ff;
}

.pbm-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pbm-card-group {
  min-height: 18px;
  color: #6f7d93;
  font-size: 12px;
}

.pbm-open-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #d9e6f8;
  font-size: 13px;
}

.pbm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  color: #8090a7;
}

.pbm-empty-title {
  color: #dbe7f7;
  font-size: 16px;
  font-weight: 600;
}

.pbm-empty-hint {
  margin-top: 8px;
  font-size: 13px;
}

.pbm-context-menu {
  position: fixed;
  z-index: 9200;
  min-width: 180px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #16202c;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  display: none;
}

.pbm-context-menu.visible {
  display: block;
}

.pbm-menu-sub {
  position: relative;
}

.pbm-submenu {
  position: absolute;
  top: -6px;
  left: calc(100% + 6px);
  min-width: 160px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #16202c;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  display: none;
}

.pbm-menu-sub:hover .pbm-submenu {
  display: block;
}

.pbm-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  background: transparent;
  color: #d6e3f7;
  font-size: 13px;
  text-align: left;
}

.pbm-menu-item.is-active {
  background: rgba(255,168,79, 0.18);
  color: #eef4ff;
}

.pbm-menu-item.is-disabled {
  opacity: 0.45;
}

.pbm-menu-item.is-disabled:hover {
  background: transparent;
  color: #d6e3f7;
}

.pbm-menu-arrow {
  margin-left: 16px;
  color: #7f8ca2;
}

.pbm-menu-divider {
  height: 1px;
  margin: 6px 0;
  background: rgba(255, 255, 255, 0.08);
}

.pbm-menu-label {
  padding: 4px 12px 6px;
  color: #7d8ca3;
  font-size: 12px;
}

.pbm-grid-scroll::-webkit-scrollbar,
.pbm-sidebar-list::-webkit-scrollbar {
  width: 8px;
}

.pbm-grid-scroll::-webkit-scrollbar-thumb,
.pbm-sidebar-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.pbm-selection-rect {
  position: fixed;
  z-index: 9300;
  border: 1px solid rgba(255,168,79, 0.55);
  background: rgba(255,168,79, 0.12);
  border-radius: 6px;
  pointer-events: none;
}

@media (max-width: 900px) {
  .pbm-dialog {
    width: 96vw;
    height: 92vh;
  }

  .pbm-body {
    flex-direction: column;
  }

  .pbm-sidebar {
    width: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .pbm-toolbar {
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 10px 0;
  }
}
