.managerDialog {
  width: min(1100px, calc(100vw - 48px));
  max-width: 1100px;
}

.browserRoot {
  display: grid;
  gap: 10px;
  min-height: 0;
}

.browserRootFill {
  height: 100%;
  grid-template-rows: auto 1fr;
}

.browserRootListOnly {
  grid-template-rows: auto 1fr;
}

.browserToolbar {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.browserToolbarRow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.browserToolbarRow > * {
  width: 100%;
  min-width: 0;
  display: flex;
  flex: 1 1 0;
}

.browserToolbarRow > * > button {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.browserToolbarZoomRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.browserToolbarFullBtn {
  width: 100%;
}

.browserToolbarFullBtn > button {
  width: 100%;
}

.browserToolbarHint {
  color: var(--text2);
  font-size: 11px;
  line-height: 1.35;
  padding: 0 2px;
  word-break: break-word;
}

.managerBody {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 14px;
  /* ~3 плитки по высоте + поиск/кнопка; дальше скролл в списке */
  min-height: 560px;
  max-height: min(84vh, 820px);
}

.managerBodyFill {
  max-height: none;
  height: 100%;
  min-height: 0;
}

.managerBodyListOnly {
  grid-template-columns: 1fr;
  min-height: 0;
  max-height: none;
  height: 100%;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.sideAddBtn {
  width: 100%;
  flex: 0 0 auto;
}

.sideAddBtn > * {
  width: 100%;
  max-width: 100%;
  display: flex;
  box-sizing: border-box;
}

.sideAddBtn button {
  width: 100%;
  box-sizing: border-box;
  flex: 1;
}

.list {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 2px;
}

.tile {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--color-overlay-dark-2);
  position: relative;
}

.tileSelected {
  border-color: var(--color-accent, #a78bfa);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-accent, #a78bfa) 45%, transparent);
}

.tileActive {
  outline: 1px solid color-mix(in srgb, var(--color-accent, #c9a227) 70%, transparent);
}

.tileDragging {
  opacity: 0.55;
}

.tileDropBefore::before,
.tileDropAfter::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--color-accent, #a78bfa);
  z-index: 2;
}

.tileDropBefore::before {
  top: -1px;
}

.tileDropAfter::after {
  bottom: -1px;
}

.tileBody {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 8px;
  cursor: pointer;
  display: grid;
  gap: 6px;
  font: inherit;
}

.tileImg,
.tileImgEmpty {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background: var(--color-overlay-dark-4);
  overflow: hidden;
  position: relative;
}

.tileName {
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tileMenu {
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  padding: 8px 10px;
  font-size: 18px;
  line-height: 1;
  align-self: start;
}

.tileMenu:hover {
  color: var(--text0);
}

.previewColumn {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
  min-height: 0;
}

.previewColumnLegend {
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}

.previewLegendScroll {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.previewPane {
  width: 100%;
  /* высота ≈ 3 плитки списка */
  height: 520px;
  min-height: 520px;
  max-height: 520px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--color-overlay-dark-3);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.managerBodyFill .previewPane {
  height: 100%;
  min-height: 0;
  max-height: none;
}

.previewLargeHost {
  position: absolute;
  inset: 16px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.previewEmpty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text2);
  font-size: var(--text-sm);
  padding: 24px;
  text-align: center;
}

.previewActions {
  display: flex;
  gap: 8px;
}

.imageDrop {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--stroke-2);
  background: var(--color-overlay-dark-2);
  position: relative;
}

.imageDropEmpty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 112px;
  text-align: center;
  padding: 8px 4px;
}

.imageDropEmpty > * {
  max-width: 100%;
}

.imageDropOver {
  border-color: var(--color-accent, #a78bfa);
}

.previewThumb {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--color-overlay-dark-4);
}
